const util = require('../utils/util.js')
const sizhu = require('../sizhu/sizhu.js')
const log = require('../log/log.js')
const app = getApp();

//十个天干       0     1     2     3    4     5     6     7    8     9
const tgArr = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
//十二个五行     0     1     2     3    4     5     6     7     8     9  
const tgPArr = ["木", "木", "火", "火", "土", "土", "金", "金", "水", "水"]
//十二个地支     0     1     2     3    4     5     6     7     8     9    10   11
const dzArr = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
//十二个五行     0     1     2     3    4     5     6     7     8     9    10   11
const dzPArr = ["水", "土", "木", "木", "土", "火", "火", "土", "金", "金", "土", "水"]
//五行               0    1     2     3     4
const wuXingArr = ["木", "火", "土", "金", "水"]
//五行颜色
const wuXingColorArr = ["#187e18", "#bd565b", "#694d18", "#ccca38", "#30aeb3"]
//十二长生
const changShengWxArr = [11, 2, 8, 5, 8]
//十二长生
const changShengArr = ["长", "浴", "冠", "官", "帝", "衰", "病", "死", "墓", "绝", "胎", "养"]
//旺相休囚死
const wangArr = ["旺", "相", "死", "囚", "休"]
//用神
const sixQinArr = ["兄弟", "子孙", "妻财", "官鬼", "父母"]
//节气
const jieQiArr = ['雨水', '惊蛰', '春分', '清明', '谷雨', '立夏', '小满', '芒种', '夏至', '小暑', '大暑', '立秋', '处暑', '白露', '秋分', '寒露', '霜降', '立冬', '小雪', '大雪', '冬至', '小寒', '大寒', '立春']
//月将
const yueJiangArr = ['神后', '大吉', '功曹', '太冲', '天罡', '太乙', '胜光', '小吉', '传送', '从魁', '河魁', '登明']
//天将
const tianJiangArr = ['贵人', '螣蛇', '朱雀', '六合', '勾陈', '青龙', '天空', '白虎', '太常', '玄武', '太阴', '天后']
//天将
const tianJiangPArr = ['土', '火', '火', '木', '土', '木', '土', '金', '土', '水', '金', '水']
//十二寄宫
const tlvJiGongGanArr = [2, 4, 5, 7, 5, 7, 8, 10, 11, 1]
//十二寄宫
const tlvJiGongZhiArr = [[], [9], [0], [], [1], [2, 4], [], [3, 5], [6], [], [7], [8]]
//刑
const xingArr = [3, 10, 5, 0, 4, 8, 6, 1, 2, 9, 7, 11]
//昼贵人
const tianJiangRule = [[1, 0, 11, 11, 1, 0, 1, 6, 5, 5], [7, 8, 9, 9, 7, 8, 7, 2, 3, 3]]
//驿马
const yiMaArr = [[7, 7], [7, 1], [3, 1], [5, 1]]
//天将解释
const tianJiangDesc = [
    "人物：尊长、父母、首领、领导、导师\n性质：贵重物品、名望高、功名第一\n性格：自尊心、面子、以领导自居",
    "人物：小人、下贱之人、骑兵、探子\n奇异：惊恐、虚惊、怪异、恐惧、闹邪、奇特、奇异、新潮、奇怪、变化\n虚假：惊吓、猜疑、疑惑、心眼多、耍手段、虚假不实、诈骗\n其他：危险、意外、麻烦、圈套、设计、策划、捆绑\n性质：快速、火光、闪电、缠绕、弯曲、细长、毒、棍\n性格：善于交际、头脑灵活、圆滑、口才好、阴险狡猾\n疾病：发炎、肿块、梦中怪异",
    "人物：眼睛、照相机、手机、短信、飞禽鸟类、羽毛、火鸟、飞机、无人机\n性质：文章、文书、通讯、信息、消息、宣传、广告\n口舌：口舌、争吵、官非、绯闻\n火电：火烧、火光、红色、光亮、光彩、晴天、烧烤\n声音：声音、口语、表达\n疾病：发烧、发炎、炎症、热性病",
    "人物：子孙、兄弟、朋友、合伙人、中介、中间人、经纪人、医生、商人、媒人、外交\n物品：柜子、棺材、外交部\n性质：交易、合作、经商、结婚、合同、存折、结交、谈判、谈朋友\n阴私：约会、赴约",
    "人物：公安、司法机关、牢狱、勾结团伙\n性质：土地、房地产、土建、土木、土堆、田园、坟墓\n争斗：争斗、打斗、钩子、勾引、牵连\n特征：迟滞、滞留、二手、旧货、收集、回收站\n性格：墨迹、拖延、迟钝、反应慢、拘束、不爱言语、好斗\n心情：担心、害怕、蒙在鼓里\n疾病：慢性病、跌打损伤\n官场：印绶",
    "性质：婚姻、喜庆、财帛、酒色、升迁、调动、庆贺、动力\n官场：官禄、干部、领导、名气\n人物：男友、新郎官\n工作：走动、升迁、调动、飞腾",
    "人物：奴、打工仔\n物品：中空之物、葫芦、空瓶、球\n性质：闲置、空房、垃圾、废弃物、破烂、被人抛弃之物\n性质：空虚、寂寞、孤独、虚情假意、单身\n虚假：虚惊、欺诈、虚假、玩笑、空话、欺骗\n合同：契约、文件、合同、文书、策划、学术、会议、证券、票据、彩票\n玄幻：僧人、道士、玄学、术数",
    "死伤：死丧、孝服、血光之灾、疾病、癌症、车祸、灾祸、死亡、战争、刀剑\n道路：道路、马路、轨道、铁路\n权力：实权、威猛、凶猛\n疾病：恶性病、肿瘤、癌症",
    "物品：衣服、十五、布匹、五谷、面食、礼品、礼物、饰品、聘礼、酒食、宴会\n职称：印绶、职称、招聘\n官场：俸禄、赏赐、职务、官服\n家属：亲戚、眷属\n祈祷：祭祀、还愿",
    "人物：盗贼、抢劫犯、小人、骗子\n脏物：脏水、污水、臭水、污染水、废水、小便、腐烂、变质\n阴私：黑色、阴暗、潮湿、违法乱纪、走私、私情\n虚假：盗贼、欺骗、隐瞒、骗子、怀疑、暧昧、假货、假冒、劣质、腐烂",
    "人物：小妾、情人、秘书、小蜜、下属、老夫人、妇女、婢女、打工妹\n物品：女人之物、月亮\n性质：秘密、阴私、奸情、暧昧、阴谋、阴暗地、背地里、密谋策划\n女性：母亲、暗中庇护、遗产、遗嘱",
    "人物：妻子、母亲、妇女\n物品：水池、池塘、泉水、河流、水货\n保护：恩泽、保佑、袒护\n阴私：暧昧、贪污、受贿、隐蔽\n后勤：后勤、售后、保洁、洗衣、女性类、服务类",
]
//月将解释
const yueJiangDesc = [
    "人物：孩子、小孩\n诗书：图书、诗、画\n河水：江河、长江、河流、溪、冰、凉、水、海、大雨、雪\n阴暗：阴私、盗贼、隐私、私情、污秽、厕所、卫生间、争讼、沉溺\n哭泣：哭、抽泣、呻吟\n身体：头、肾、泌尿、产道\n物品：帐篷、雨伞、圆环、鼓\n植物：梅花、尖长之物\n动物：鱼、熊\n农物：水稻、芝麻、酱、醋、酒水、醉客",
    "聚集：聚众、聚集、市场、菜场、市井、寺庙、帮会、协会、团体、组织、会馆、党派\n人物：仆人、腿、走动、打工男、鞋子、足\n屏障：包围、围墙、圈地、圈养、网、网络\n天魁：文学星、印绶、学问、学术、文凭、毕业证\n污秽：垃圾、垃圾堆、分辨\n仓库：储藏、仓库、缸、瓮、瓦器、沙尘暴\n地狱：刑狱、狱卒\n汇集：收敛、细碎而多、河沙、荒地",
    "人物：情人、婢女、随从、少女、少妇、打工妹、师尼、保姆\n私户：私人账户、私门、后门、女生殖器、公司、银行、酒、色、情色、阴私、酒器、小刀、小麦、带刺\n金属：玉石、镜子、珍珠、金银、黄金、白银、纯金、钱、金银首饰、圆形方正之物、铁石、石碑、墓碑、磁铁、银行卡、身份证、箱子、柜子、抽屉\n口舌：口、歌喉\n辛辣：姜、蒜、石榴\n动物：鸡、鸭、鸟、乌鸦\n疾病：肺、肿瘤",
    "传送：传输、道路、往来、管道、通道、气管、出货\n身体：下肢、腿\n人物：巡逻、巡查、保卫、保安、业务员、税务人员、官员、邮差、迎宾、接待\n性质：邮寄、快递、物流\n金属：带尖金属、兵器、铠甲、长矛、枪支、针、钉子、铁匠、僧人、钱财、火车、铁路、铁链\n驿站：宾馆、驿站、寺庙、庙堂\n石头：玉石、石磨、玉器\n疾病：身体、肺、大肠、骸骨、经脉、脉络\n河水：江\n白虎：肃杀之气、死尸、丧孝、灾厄",
    "酒食：婚宴、饭店、宴会、庆贺、茶馆\n人物：婚姻、妇女、亲戚、眷属、寡妇\n井宿：矿井、煤炭矿、井、天井、前院、帘子、木库、田野、公园、园林、果园、苗圃、柴房\n衣物：冠带、衣服、聘礼、礼物、礼品、印信、帽子、裁缝\n食物：食品、粮食、小米、谷栗、茶叶、木棉、小麻、药品\n鬼宿：祭祀、鬼神、丧事、太平间、坟地\n疾病：胃病、脾、伤食、反胃、呕吐",
    "身体：眼睛、头\n物品：马、车、使者、亭长、营卫、旅客\n屋子：堂屋、大堂、办公室、令堂、母亲、大堂经理\n服饰：官服、制服、高处、头面、旗帜、衣架、高柜、帐\n性质：美丽、风光、风景、观光、街道、热闹、华丽、明亮、闹市、光明、信息、文明、文书、文人、礼仪、妇女、美容\n彩画：画、丝绵、丝绸、锦绣\n红色：花、红色、火烛、光影、血光、官事\n动物：马、鹿、獐\n农物：蚕豆、小豆、红豆、蚕、丝绸\n天气：晴天、霞",
    "动物：蛇、蚯蚓、蝉、飞虫\n双份：双胞胎女、双份工作、兼职\n光明：火光、花烛、灯、烛火\n厨房：窑、炕\n怪异：奇特、奇异、艺术、文学、忧惊、梦寐、神经、癫狂、贱、轻薄、精神病人\n身体：眼、头面、牙齿、变形、歪斜、发炎、肿胀、男生殖器、弓、绳索、曲折、蜿蜒\n物品：花、布帛、长管、弯曲乐器、穿越、横跨、胁迫、要挟、牵连、搅合\n丧事：丧车、羽翼、羽毛\n农物：赤豆、长形状物、豆角、丝瓜",
    "性质：鼓动、主动、奋发\n领袖：首领、头领、名列前茅\n凶猛：霸气、住宅、宰杀之神\n观察：检察院、鉴察、公安局、武职部门\n咽喉：要塞、开关\n宰杀：屠夫、宰杀、破坏、凶恶\n屏障：坚硬、盾、城墙、高岗、高岭、坡、岗、麦地、盔甲\n边塞：边关、边塞、险阻之地\n刑狱：监狱、公安、天关、天罗、牢狱、抓捕\n争斗：打斗、打架、下象棋、对弈\n水库：沟渠、水库、水坑、水池、下水道\n物品：砖瓦、缸瓮、浴缸、浴池、水缸、鱼缸、饮水机、马槽、石栏、寺观、坟墓、沼泽",
    "车船：车、马、舟、船、骑士、轮、马车、出租车、四轮车\n门户：门、窗、门户、单位、公司、经纪人、门卫、房东、对外账户、身份证、户口本\n木器：棺材、箱子、骨灰盒、砧板、床、小型家具、茶几、矮桌\n动物：兔子、狐狸、阴私、丧事、门户往来\n人物：兄弟、姐妹、荡妇、长男、太子、孩子\n竹木：竹、木、竿、篱笆、青菜、风、柳、笙簧、箫、笛、桥、驴、骡",
    "人物：夫婿、医生、文章、书籍、书本、文人、会计\n木器：书案、办公桌、椅子、香炉、棋子、大树、栋梁、花木、棉、屏风、房梁、桥梁、栋梁、柱子、脊柱\n身体：须发、肝胆、筋脉、风、山林、草庐、木从、柴薪、山房、道士、虎豹、狸猫、斑纹\n官员：天吏、官府、衙门、官员、公务员、邮政\n寅性：鬼门、上平下有腿，书桌、椅子、须发、方脸",
    "人物：长者、老者、老人\n田园：田、园、菜园、矿山、仓库、储藏室、后宅\n食品：饮食、神佛、僧舍、山神、土地、水坑、桥梁\n身体：腹、脾、腹泻\n物品：锁、钥匙、环、柜台、秤、尺、量具、罐、地洞、缸\n生意：柜台、收银台\n动物：牛、硬壳动物、龟、鳖、螃蟹、多足动物、蜈蚣\n庄稼：大豆、黄豆、姜\n外貌：丑陋、秃头、矮子",
    "人物：女人、妻、媳、妇人、奶妈、船员、孩子\n静水：水、软、圆形、湖泊、墨池、纯净水、乳、冰、丝、奶、糖水、莲塘、浴盆、浴室\n动物：鼠、燕、蝙蝠、鱼虾\n物品：瓶、盏、墨、伞、笼、瓦、布帛\n家宅：内室、卧室、暗处\n身体：膀胱、腰、肾、精液、子宫、乳房、女经\n疾病：血疾、冷、受凉\n农物：黑豆、燕窝",
]
//岁煞，name：名字，type：0：干，1：支，source：来源，destination：目标，category：类别，desc：解释
const suiShaRule = [
    { "name": "太岁", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "category": "吉凶", "desc": "天子、元首、总统、政府、董事长、区域范围最高领导" },

    { "name": "病符", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[11], [0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]], "category": "疾病", "desc": "临干或发用，往年旧事复发、疾病、灾害" },

    { "name": "大耗", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[6], [7], [8], [9], [10], [11], [0], [1], [2], [3], [4], [5]], "category": "钱财、感情、灾难", "desc": "破碎、耗费、破财、骨肉分离、岁月二破有大灾、出行催促、产品冲击" },

    { "name": "丧门", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [0], [1]], "category": "疾病", "desc": "死丧、哭泣、盗贼、遗亡" },

    { "name": "吊客", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[10], [11], [0], [1], [2], [3], [4], [5], [6], [7], [8], [9]], "category": "疾病", "desc": "死亡、吊丧、加年命或干支有孝服之象" },

    { "name": "官符", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[4], [5], [6], [7], [8], [9], [10], [11], [0], [1], [2], [3]], "category": "是非", "desc": "官非、词讼" },

    { "name": "白虎", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[8], [9], [10], [11], [0], [1], [2], [3], [4], [5], [6], [7]], "category": "吉凶", "desc": "凶险、血光、惊恐、服丧" },
]
//季煞
const jiShaRule = [
    { "name": "孤神", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[5], [8], [11], [2]], "category": "婚姻", "desc": "男主克妻" },

    { "name": "寡宿", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[1], [4], [7], [10]], "category": "婚姻", "desc": "女主妨夫或父母兄弟离异" },

    { "name": "丧车", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[9], [0], [3], [6]], "category": "死丧", "desc": "主死丧之事、克日主病危" },

    { "name": "飞祸", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[8], [2], [5], [11]], "category": "计划", "desc": "百事皆忌" },

    { "name": "无成", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[9], [0], [3], [6]], "category": "成功", "desc": "也称四废、百事不成" },

    { "name": "浴盆", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[4], [7], [10], [1]], "category": "疾病、生产", "desc": "病凶产吉" },

    { "name": "天目", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[4], [7], [10], [1]], "category": "鬼神", "desc": "鬼祟" },

    { "name": "哭神", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[7], [10], [1], [4]], "category": "哭丧", "desc": "与白虎并有哭声、下泪大凶" },

    { "name": "贼神", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[3], [6], [9], [0]], "category": "盗贼", "desc": "主奸私、贼盗、占失物较多" },

    { "name": "游神", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[1], [0], [11], [10]], "category": "行人", "desc": "占行人加孟未来、加仲在途、加季即至" },

    { "name": "戏神", "type": 1, "source": [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]], "destination": [[5], [0], [9], [4]], "category": "动作", "desc": "游戏、嬉闹" },
]
//月煞
const yueShaRule = [
    { "name": "天马", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[2], [4], [6], [8], [10], [0], [2], [4], [6], [8], [10], [0]], "category": "计划", "desc": "主迁移更改火速之事、主远行出征、宜占迁动更改之事情" },

    { "name": "生气", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[10], [11], [0], [1], [2], [3], [4], [5], [6], [7], [8], [9]], "category": "吉凶、生产、钱财", "desc": "生气解凶增吉、乘龙有财婚喜、乘后合主怀孕" },

    { "name": "死气", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[4], [5], [6], [7], [8], [9], [10], [11], [0], [1], [2], [3]], "category": "吉凶、疾病、生产", "desc": "主死丧、孝服、病产最忌" },

    { "name": "天医", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [0], [1]], "category": "疾病", "desc": "日克天医为医不精、天医克人为医药不当" },

    { "name": "地医", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[8], [9], [10], [11], [0], [1], [2], [3], [4], [5], [6], [7]], "category": "疾病", "desc": "" },

    { "name": "飞魂", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[9], [10], [11], [0], [1], [2], [3], [4], [5], [6], [7], [8]], "category": "疾病", "desc": "占病主魂飞" },

    { "name": "天诏", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[9], [10], [11], [0], [1], [2], [3], [4], [5], [6], [7], [8]], "category": "升迁", "desc": "占升迁有恩施" },

    { "name": "血支", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[11], [0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]], "category": "吉凶、生产", "desc": "主血光、产孕" },

    { "name": "游煞", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [0]], "category": "吉凶、计划", "desc": "主出行不利、出行容易有灾祸，入传或见年命上主行动。" },

    { "name": "月破", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[6], [7], [8], [9], [10], [11], [0], [1], [2], [3], [4], [5]], "category": "婚姻", "desc": "主破坏离散、可解冤忧、吉事不成、占婚姻为破裂" },

    { "name": "月厌", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[0], [11], [10], [9], [8], [7], [6], [5], [4], [3], [2], [1]], "category": "物品、仇怨、疾病、家宅、梦", "desc": "占物为污秽不净之物、为暧昧、私邪、不正之神、主诅咒冤仇不明、占病主缠绵、占宅月厌加支有鬼崇之象、月厌加虎克日病死、加朱勾忧惊、加蛇怪梦" },

    { "name": "成神", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[5], [8], [11], [2]], "category": "吉凶", "desc": "旺相生合百事皆吉" },

    { "name": "皇恩", "type": 1, "source": [[2, 8], [3, 9], [4, 10], [5, 11], [6, 0], [7, 1]], "destination": [[7], [9], [11], [1], [3], [5]], "category": "升迁", "desc": "主升迁之事" },

    { "name": "天鸡", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[11], [10], [9], [8], [7], [6], [5], [4], [3], [2], [1], [0]], "category": "信息", "desc": "主信息、天鸡并雀、信至、行人来" },

    { "name": "飞廉", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[8], [9], [10], [5], [6], [7], [2], [3], [4], [11], [0], [1]], "category": "吉凶", "desc": "主意外灾祸" },

    { "name": "天鬼", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[9], [6], [3], [0]], "category": "疾病、生产", "desc": "主病亡产死" },

    { "name": "四煞", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[7], [4], [1], [10]], "category": "吉凶", "desc": "主凶灾" },

    { "name": "谩语", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[4], [5], [6], [7], [8], [9], [10], [11], [0], [1], [2], [3]], "category": "性格", "desc": "玩笑、胡说八道、天空并、主事空不实" },

    { "name": "桃花", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[3], [0], [9], [6]], "category": "婚姻", "desc": "主桃花" },

    { "name": "悬索", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[3], [0], [9], [6]], "category": "吉凶、疾病、偷盗", "desc": "占灾病有缢死鬼为祸、占贼必至屋而下" },

    { "name": "长绳", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[1], [0], [11], [10], [9], [8], [7], [6], [5], [4], [3], [2]], "category": "死亡", "desc": "鬼主缢死" },

    { "name": "奸门", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[8], [11], [2], [5]], "category": "婚姻、性格", "desc": "邪神、主奸淫、奸邪之事、测婚姻查之" },

    { "name": "阴奸", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[9], [8], [7], [6], [5], [4], [3], [2], [1], [0], [11], [10]], "category": "婚姻、性格", "desc": "奸邪不正" },

    { "name": "华盖", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[10], [7], [4], [1]], "category": "钱财、疾病、事情", "desc": "主有损亡、华盖覆日人昏晦、主昏迷糊涂" },

    { "name": "天盗", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[2], [11], [8], [5]], "category": "偷盗", "desc": "主有盗贼" },

    { "name": "亡神", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[5], [2], [11], [8]], "category": "疾病、钱财", "desc": "主遗亡、损耗" },
]

//旬煞
const xunShaRule = [
    { "name": "旬首", "type": 2, "source": [], "destination": [], "category": "吉凶", "desc": "逢凶化吉、占人为头领、领班、领导" },

    { "name": "闭口", "type": 2, "source": [], "destination": [], "category": "事情", "desc": "不答应、不回答、不说话、拒绝" },

    { "name": "丁马", "type": 2, "source": [], "destination": [], "category": "计划", "desc": "变动、更改、更换" },

    { "name": "亡神", "type": 2, "source": [], "destination": [], "category": "疾病、人物、生产、计划", "desc": "主丧亡、走失、手术、变化、更改" }
]
//日干煞
const riGanShaRule = [
    { "name": "日德", "type": 0, "source": [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]], "destination": [[2], [8], [5], [11], [5]], "category": "吉凶", "desc": "临日入传转祸为福、乘鬼发用德能化鬼为吉、德传入鬼为明德暗鬼为凶" },

    { "name": "日禄", "type": 0, "source": [[0], [1], [2, 4], [3, 5], [6], [7], [8], [9]], "destination": [[2], [3], [5], [6], [8], [9], [11], [0]], "category": "钱财、疾病", "desc": "占病闭口或禄绝为无法进食有性命之忧为凶、临日入传为吉、宜旺不宜空克绝墓" },

    { "name": "天罗", "type": 0, "source": [[0], [1], [2, 4], [3, 5], [6], [7], [8], [9]], "destination": [[3], [5], [6], [8], [9], [11], [0], [2]], "category": "吉凶", "desc": "静吉动凶" },

    { "name": "羊刃", "type": 0, "source": [[0], [2, 4], [6], [8]], "destination": [[3], [6], [9], [0]], "category": "吉凶", "desc": "静吉动凶、又主血光、伤灾、占病临白虎手术、羊刃逢冲带丁马为动为凶" },

    { "name": "喜神", "type": 0, "source": [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]], "destination": [[2], [10], [8], [6], [4]], "category": "事情", "desc": "喜庆" },

    { "name": "游都", "type": 0, "source": [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]], "destination": [[1], [0], [2], [5], [8]], "category": "偷盗", "desc": "兵、贼来路" },

    { "name": "鲁都", "type": 0, "source": [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]], "destination": [[7], [6], [8], [11], [2]], "category": "偷盗", "desc": "兵、贼去路" }
]
//日支煞
const riZhiShaRule = [
    { "name": "驿马", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[8], [5], [2], [11]], "category": "计划、速度", "desc": "道路之象、入课传为动象、与吉神并主吉动迅速，与凶神反之" },

    { "name": "地网", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [0]], "category": "吉凶、计划", "desc": "宜静不宜动" },

    { "name": "劫煞", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[11], [8], [5], [2]], "category": "偷盗、吉凶、钱财", "desc": "主打劫、强盗、破财、灾祸、利公务员考试" },

    { "name": "灾煞", "type": 1, "source": [[2, 6, 10], [11, 3, 7], [8, 0, 4], [5, 9, 1]], "destination": [[0], [9], [6], [3]], "category": "吉凶、钱财、疾病", "desc": "披麻、主灾祸、杀伤、破财、损口、疾病、灾厄" },

    { "name": "破碎", "type": 1, "source": [[2, 5, 8, 11], [0, 3, 6, 9], [1, 4, 7, 10]], "destination": [[9], [5], [1]], "category": "物品、钱财、情感、生产", "desc": "物破碎、破财、情感破裂、剖腹产" },

    { "name": "合神", "type": 1, "source": [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11]], "destination": [[1], [0], [11], [10], [9], [8], [7], [6], [5], [4], [3], [2]], "category": "合作、疾病、是非", "desc": "利于合作、病难医治讼难解" },

    { "name": "收魂", "type": 1, "source": [[0, 11], [2, 3], [5, 6], [8, 9]], "destination": [[4], [7], [10], [1]], "category": "吉凶、疾病", "desc": "乘玄武、占病凶、主遗亡、损耗" }
]
/******************************************六亲纳音*************************************** */
const sixQinDesc = [
    "兄弟：代表兄弟、姐妹、朋友、同事、阻隔、竞争、破财、破耗、风云、门户、厕所、墙壁、贪财、赌博、抢劫、争夺、手臂、胳膊、腿、脚、牙、胃、肩、膀胱、饮食不纳、消化不良等。一切同类之人皆为兄弟，占财物以此有劫财之神，占谋事以此为阻隔之神。占表兄弟、占不亲近之同事、邻居不以兄弟爻为用神，而以应为用神。",
    "子孙：代表儿女、子孙、孩子、婴儿、晚辈、后代、侄女、侄儿、外甥、良将、僧道、出家人、教徒、士兵、公安、福神、财源、道路、走廊、动物、日、月、星、辰、晴天、饮酒、快乐、娱乐、无忧无虑、医生、营养、药品、乳房、五官、小便、咒符、气功师、巫婆、神汉、食道、呼吸道、气管、眼、耳、口、鼻、血管、毛孔、肠、生殖器、骨髓等。子孙为福德之神，为制鬼之神，为解忧之神，又为剥官引职之神。故谓之子孙乃是福神，诸事见之为喜，独占功名者忌之。",
    "妻财：代表妻子、爱人、女性、恋爱对象、女友、奴仆、保姆、佣人、随从、雇员、财产、资金、经济、价格、钱币、器物、仓库、粮食、灶、厨房、植物、货物、嫁妆、俸禄、工资、收入、报酬、费用、道理、脏物、装载物品、珠宝、首饰、日用品、晴天、毛发、饮食、血液、呼吸、眼泪、屎尿、汗水、乳汁、鼻涕、津液、腰、肛门等。",
    "官鬼：代表丈夫、男人、功名、名次、名字、官府、公安、官司、公家、司法部门、上级领导、雷电、雾、烟、鬼神、盗贼、坏人、逃犯、乱党、灾祸、忧愁、官位、工作、升学、职业、主人、疾病、尸体、死者、病灶、病毒、杂念，烦恼等。一切拘束我身者是也。",
    "父母：代表父母、爷爷、奶奶、姥姥、姥爷、姑妈、姑夫、姨妈、姨夫、舅妈、舅舅、老师、义父、义母、岳父、岳母、长辈、老人、天地、土地、坟墓、城池、围墙、房舍、建筑、工程、自行车、汽车、火车、船、飞机等交通工具，雨、雪、雨衣、雨伞、衣服、鞋帽、布匹、头巾、口罩、报告、文章、文件、书籍、报纸、信件、合同、信息、消息、信号、学校、医院、头、面部、胸、背、腹、臀部、病房、被褥、床单、工作单位、衙门等。在人通变，一切庇祐我身者为父母。"
]
/******************************************天干纳音*************************************** */
const ganZhiDesc = [
    "甲子乙丑海中金：石油、珍珠、海矿、金库、海底沉船等。以子为水，又为湖，又为水旺之地，兼金死于子、墓于丑，水旺而金死、墓，故曰海中之金，又曰气在包藏，使极则沉潜。",
    "丙寅丁卯炉中火：煤炉、厨房、灶台、柴草、炼钢炉、枯死植物、饭馆、火锅等。以寅为三阳，卯为四阴，火既得位，又得寅卯之木以生之，此时天地开炉，万物始生，故曰炉中火，天地为炉，阴阳为炭。",
    "戊辰己巳大林木：森林、山野、树木、花草、电线杆、木材批发部、林场、花园等。以辰为原野，巳为六阴，木至六阴则枝藏叶茂，以茂盛之大林木而生原野之间，故曰大林木，声播九天，阴生万顷。",
    "庚午辛未路旁土：道路、马路、清洁工、建筑工、干土、土堆、建筑工、垃圾堆等。以未中之土，生午木之旺火，则土旺于斯而受刑。土之所生未能自物，犹路旁土也，壮以及时，乘厚戴木，多不喜木。",
    "壬申癸酉剑锋金：宝剑、凶器、兵器、椎盘、古董店、军队、晨练者、武术家等。以申酉金之正位，兼临官申、帝旺酉，金既生旺，旺则诚刚，刚则无逾于剑峰，故曰剑峰金。虹光射斗牛，白刃凝霜雪。",
    "甲戌乙亥山头火：夕阳、热气、烽火台、火山、霓虹灯、信息战、发电厂、机房等。以戍亥为天门，火照天门，其光至高，故曰山头火也，天际斜晖，山头落日散绮，因此返照舒霞，木白金光。",
    "丙子丁丑涧下水：云、自来水、灯油、喷泉、酒店、池塘、山涧、水源、水厂等。以水旺于子衰于丑，旺而反衰则不能成江河，故曰涧下水，出环细浪，雪涌飞淌，汇流三峡之倾澜，望下寻之倒。",
    "戊寅己卯城头土：城郭、山岳、城墙、住宅、高楼大厦、八达岭、长城、碉堡等。以天干戊、己属土，寅为艮山，土积为山，故曰城土也，天京玉垒，帝里金城，龙蟠千时之形，虎踞四维之势也。",
    "庚辰辛巳白腊金：蜡、玉、宝石、矿石、首饰、护肤品、化妆品、熔化等。以金养于辰而生于巳，形质初成，未能坚利，故曰白蜡金，气渐发生，交栖日月之光，凝阴阳之气。",
    "壬午癸未杨柳木：杨柳、柔木、花草、灌木丛、花柳巷、牙签、公园、无立场等。以木死于午墓于未，木既死墓，唯得天干壬癸之水以生之，终是柔木，故曰杨柳木，万缕不蚕之丝，千条不了之线。",
    "甲申乙酉泉中水：水井、溪沟、山泉、喷泉、矿泉水、油井、矿井、泉州、湿润等。金既临官在申，帝旺在酉，旺则生自以火，然方生之际方量未兴，故曰井泉水也。气息在静，过而不竭，出而不穷。",
    "丙戌丁亥屋上土：瓦片、飞贼、墙壁、房子、砖瓦、烂尾楼、坟墓、装修业等。以丙丁属火，戍亥为天门，火既炎上则土非在下，故曰屋上土。",
    "戊子己丑霹雳火：雷、烟火、闪电、电焊、火车、火箭、闪电、发电厂、变压器、高压线等。丑属土，子属水，水居正位而纳音乃火，水中之火非龙神则无，故曰霹雳火，电击金蛇之势，云驰铁骑之奔，变化之象。",
    "庚寅辛卯松柏木：松树、柏树、电杆、铁塔、烈士陵园、不朽、刚直、纪念碑、栋梁之才等。以木临官在寅，帝旺在卯，木既生旺，则非柔弱之比，故曰松柏木也。积雪凝霜参天覆地，风撼笙簧，再余张旌施。",
    "壬辰癸巳长流水：河流、溪水、水沟、工厂流水线、口水等。辰为水库，巳为金的长生之地，金则生水，水性已存，以库水而逢生金，泉源终不竭，故曰长流水也。势居东南，贵安静。",
    "甲午乙未沙中金：钻石、纯金、合金、小首饰、沙漠、金属、人才等。午为火旺之地，火旺则金败，未为火衰之地，火衰败而金冠带，败而方冠带，未能作伐，故曰砂中金也。",
    "丙申丁酉山下火：野火、路灯、萤火、香火、土窑、砖瓦窑、热电厂、炉灶等。申为地户，酉为日入之门，日至此时而无光亮，故曰山下火。",
    "戊戌己亥平地木：栋梁、树木、建材、枕木、木桥等。戊为原野，亥为生木之地，夫木生于原野，则非一根一林之比，故曰平地木，惟贵雨露之功，不喜霜雪之积。",
    "庚子辛丑壁上土：屋宇、洞壁、墙壁、挂历、飞贼、招牌、玻璃窗、涂料等。丑虽是土家正位，而子则水旺之地，土见水多则为泥也，故曰壁上土也，气屋开塞，物尚包藏，掩形遮体，内外不及。",
    "壬寅癸卯金箔金：金饰、描金、镀金、首饰、纸钱、表面风光等。寅卯为木旺之地，木旺则金赢，且金绝于寅，胎于卯，金既无力，故曰金箔金。",
    "甲辰乙巳覆灯火：灯烛、灯光、电筒、佛堂、寺庙、路灯、电筒等。辰为食时，日之将午，艳阳之势光于天下，故曰覆灯火，金盏摇光，玉台吐艳，照日月不照处，明天下未明时。",
    "丙午丁未天河水：月轮、雨、水光、瀑布、水塔、牛郎织女等。丙丁属火，午为火旺之地，而纳音乃水，水自火出，非银汉而不能有也，故曰天河水，气当升齐，沛然作霖，生旺有济物之功。",
    "戊申己酉大驿土：稻田、大路、坦途、空旷之地、高速公路、操场、国道等。申为坤，坤为地，酉为兑，兑为泽，戊己之土加于坤泽之上，非比他浮沉之土，故曰大驿土，气以归息，物当收敛，故云。",
    "庚戌辛亥钗钏金：钗钏、首饰、珠宝、文物、古董、钟鼎、首饰加工店等。金至戍而衰，至亥而病，金既衰病则诚柔矣，故曰钗钏金，形已成器，华饰光艳乎?生旺者乎?戳体火盛伤形，终不喜。",
    "壬子癸丑桑柘木：湿木、树木、假山、养蚕业、丝绸、高档面料故乡（桑梓地）等。子属水而丑属金，水生木而金则伐之，犹桑柘方生而人便以戕伐。故曰桑柘木。",
    "甲寅乙卯大溪水：雨水、河流、露珠、洪水、大江、郊游、水运、淋浴等。寅为东旺，卯为正东，水流正东，则其性顺，而川涧池沼俱合而归，故曰大溪水。",
    "丙辰丁巳沙中土：河谷、平原、湿泥、沙浴、紫砂壶、沙漠、堤岸、海滩等。土库在辰，而绝在巳，而天本丙丁之火至辰为冠带，而临官在巳，土既张绝，得旺火生之而复兴，故曰沙中土。",
    "戊午己未天上火：太阳、月亮、桂花、闪电、空难、流星、陨石、火箭等。午为火旺之地，未、己之木又复生之，火性炎上，及逢生地，故曰天上火。",
    "庚申辛酉石榴木：石榴、结石、牙齿、水果店、肿瘤、青春痘、卵子等。申为七月，酉为八月，此时木则绝矣。惟石榴之木复实，故曰石榴木;气归静肃，物渐成实，木居金生其味，秋果成实矣。",
    "壬戌癸亥大海水：海洋、浊水、渊海、清水、远洋轮、海量、上海、百川、出海口等。水冠带在戍，临官在亥，水则力厚矣。兼亥为江，非他水之比，故曰大海水。势起大门，生旺不泛，死绝不洄。"
]
/******************************************十二长生*************************************** */
const changShengDesc = [
    "长生：含有出生，生长，来源，起点，帮助，依靠，哺育，源泉，根子，原始，苏醒，获救，救助，产生，寻找，得到，发生，吃饭的意思。",
    "沐浴：含有洗澡，入水，裸体，淫乱，淫秽，脱衣，恩泽，好处，有利，暴露，光秃秃，光溜，享受，坦诚，大小便，睡觉，破败，难看，无耻，滋润，照顾，等意思。",
    "冠带：含有穿衣，整装，和衣，打扮，包装，装饰，衣服，升级，荣誉，带帽，入伍，遮盖，外表，高贵等意思。",
    "临官：含有公家的，官府，有病，灾祸，有男人在身边，离死不远，巴结当官的，阿谀奉承，出仕，当官，有官运，有地位，公务员等意思。",
    "帝旺：含有荣发，发达，得意，精神，兴奋，神气，有力，雄壮，高大，擅长，强大，辉煌，欣欣向荣，腾达，有权，极限，高潮，顶点等意思。",
    "衰：含有无力，软弱，衰弱，弱小，不景气，弱智，败落，力小，倒霉，退缩，没靠山，弱点，胆小，虚弱，矮小，无能，没本事，不学无术，高不成低不就，不敢反抗等意思。",
    "病：含有疾病，病灶，瘟神，讨厌，憎恨，仇人，仇视，不足之处，缺点，毛病，弱点，漏洞，把柄，要害，心病，腐败，问题等意思。",
    "死：含有死亡，转牛角尖，不灵活，不能变通，滞留，终结，完蛋，认死理，一条道走到黑，没有余地，不景气，无生气，无活力，呆板，笨拙，想不开，心胸狭隘，无退路，寂静，安静，可怕等意思。",
    "墓：含有包容，收藏，埋藏，关闭，收拾，存放，管理，属于，控制，操纵，指挥，管制，包含，囊括，陷阱，不自由，入迷，受管束，隐藏，保护，保卫，围栏，仓库，权限，昏迷，昏沉，糊涂，黑暗，不流畅，不畅通，结束，阻力，阻塞等意思。",
    "绝：含有无退路，危险，绝地，绝境，悬崖，分手，断绝，背水一战，失望，心灰意冷，死心，无可救药，无能为力，无情，冷酷，不通融，停止，消失，无影无踪，把事情做绝，把话说绝等意思。",
    "胎：含有怀胎，酝酿，初步打算，计划，形成，先天的，天生的，本性难移，初级，勾连，牵挂，操心，想法，幼稚，弱小，年龄小，起步等意思。",
    "养：含有出生，生长，寄托，收养，休养，疗养，休息，依靠，营养，滋养，过继，培养，养育，扶持，扶助，怀疑，不放心，不塌实，心虚等意思。"
]

Page({
    data: {
        solarTime: '',
        week: '',
        lunarDate: '',
        x: 0,
        y: 0
    },
    //分享小程序
    onShareAppMessage: function () {
        return {
            title: '分享六壬行给你的伙伴吧',
            path: '/pages/index/index',
            imageUrl: '/images/6RXSHARE.png'
        }
    },
    //样式自适应
    autoStyle: function () {
        var systeminfo = wx.getSystemInfoSync();

        //px为单位
        var sW = systeminfo.screenWidth;
        var sH = systeminfo.screenHeight

        var rate = 750 / sW;

        //rpx为单位
        var rW = parseInt(sW * rate)
        var rH = parseInt(sH * rate)

        //time的高度
        var timeH = rH * 0.12

        //solarH
        var solarH = rH * 0.04

        //lunarH
        var lunarH = rH * 0.04

        //上面高度
        var upH = rH * 0.074

        //pageH
        var pageH = rH * 0.037


        this.setData({
            timeH: timeH,
            solarH: solarH,
            lunarH: lunarH,
            upH: upH,
            pageH: pageH,
        })
    },
    onLoad: function () {
    },
    //主要方法和画圆
    onShow: function () {
        //初始化跳转参数
        this.yingQiJump = false

        //运行开始时间
        var start = new Date().getTime();

        //获取全局变量
        var nowDate = app.globalData.nowDate
        //var nowDate = new Date("2039/1/7 14:00:00")
        var longitude = app.globalData.longitude

        log.info('paipan-onShow-option-这里是打印全局变量nowDate', nowDate)
        log.info('paipan-onShow-option-这里是打印全局变量longitude', longitude)
        log.addFilterMsg('paipanOnShowOption')

        //自适应高度
        this.autoStyle()

        //自定义弹窗
        this.dialog = this.selectComponent(".mydialog");
        //自定义弹窗
        this.shaDialog = this.selectComponent(".shaDialog");

        //获取时间、农历、星期、天干地支、天干地支五行
        var ob = this.getTimeData(nowDate, longitude)

        //获取当前月将列表、节气数据
        var tianPanObj = this.getTianPanList(nowDate, ob)

        //获取衰旺、长生
        this.getWangList(tianPanObj, ob)
        this.getChangShengList(tianPanObj, ob)

        //获取天将列表
        this.getTianJiangList(tianPanObj, ob)

        //获取四课
        this.getFourLesson(tianPanObj, ob)

        //获取三传
        this.getThreeProcess(tianPanObj, ob)

        this.tianPanObj = tianPanObj

        console.log("打印tianPanObj所有数据");
        console.log(tianPanObj);

        this.setData({
            qinList: tianPanObj.qinList,
            procList: tianPanObj.procList,
            jiangList: tianPanObj.jiangList,
            siKeList: tianPanObj.fourLessonShowList.slice().reverse()
        })

        var systeminfo = wx.getSystemInfoSync();

        //px为单位
        var sW = systeminfo.screenWidth
        var sH = systeminfo.screenHeight

        var rate = 750 / sW;

        //屏幕长宽比
        var hwNum = sH / sW

        //pad的参数
        var pam = 1
        var heiPam = 1
        if (hwNum < 1.4) {
            pam = 0.75
            heiPam = 1.2
        }

        //rpx为单位
        var rW = parseInt(sW * rate)
        var rH = parseInt(sH * rate)

        console.log(sW);
        console.log(sH);

        var width = rW * 1.4
        var height = rW * 1.4 * 0.667
        var tianDiPanMH = parseInt(rH * 0.012 * pam * heiPam)

        this.setData({
            tianDiPanMH: tianDiPanMH,
            cW: width,
            cH: height,
            yueJiangL: "(" + tianPanObj.yueJiangZhiName + "将 " + tianPanObj.yueJiangName + ")"
        })

        //天地盘
        wx.createSelectorQuery()
            .select('#myCanvas') // 在 WXML 中填入的 id
            .fields({ node: true, size: true })
            .exec((res) => {
                // Canvas 对象
                const canvas = res[0].node
                // 渲染上下文
                const ctx = canvas.getContext('2d')

                // Canvas 画布的实际绘制宽高
                const width = res[0].width
                const height = res[0].height

                console.log(width);
                console.log(height);

                // 初始化画布大小
                const dpr = wx.getWindowInfo().pixelRatio
                console.log(dpr)

                canvas.width = width * dpr
                canvas.height = height * dpr

                this.widthO = width
                this.heightO = height

                ctx.scale(dpr, dpr)

                // 清空画布
                ctx.clearRect(0, 0, width, height)

                //文字大小
                var fontSize = parseInt(width / 25 * pam)
                var littleFontSize = parseInt(width / 30 * pam)

                //确定圆心
                var x = parseInt(width / 2)
                var y = parseInt(height / 2)
                //确定半径
                var r = width / 12 * pam
                this.rO = r
                //确定半径差值
                var offset = width / 12 * pam
                this.fO = offset
                //确定每次绘制的弧度
                var one = Math.PI / 6
                //确定每次分割线的弧度
                var angle = 2 * Math.PI / 360 * 30
                //开始弧度
                var startAngle = 2 * Math.PI / 360 * 90
                //减少的半径,调整字体中心
                var little = width / 23 * pam

                //定义初始数据
                var textX
                var textY
                var start
                var end

                //绘制内部第四个圆圈
                ctx.beginPath()
                ctx.arc(x, y, r + 3 * offset, 0, 3 * Math.PI)
                ctx.lineCap = "butt"
                ctx.lineWidth = 1
                ctx.stroke()

                //绘制内部第三个圆圈
                ctx.beginPath()
                ctx.arc(x, y, r + 2 * offset, 0, 2 * Math.PI)
                ctx.lineCap = "butt"
                ctx.lineWidth = 1
                ctx.stroke()

                //绘制内部第二个圆圈
                ctx.beginPath()
                ctx.arc(x, y, r + offset, 0, 2 * Math.PI)
                ctx.lineCap = "butt"
                ctx.lineWidth = 1
                ctx.stroke()

                //绘制最内部第一个圆圈
                ctx.beginPath()
                ctx.arc(x, y, r, 0, 2 * Math.PI)
                ctx.lineCap = "butt"
                ctx.lineWidth = 1
                ctx.stroke()

                for (var i = 0; i < 12; i++) {
                    start = one * i + one * 0.5
                    end = one * (i + 1) + one * 0.5

                    //绘制最外层圆圈，顺便在每个点画条线指向到最内的圆圈
                    ctx.beginPath()
                    ctx.arc(x, y, r + 4 * offset, start, end)
                    ctx.lineCap = "butt"
                    ctx.lineWidth = 1
                    textX = x + Math.cos(startAngle / 2 + angle * i) * r
                    textY = y + Math.sin(startAngle / 2 + angle * i) * r
                    ctx.lineTo(textX, textY)
                    ctx.stroke()

                    //后期写旺相休囚死、还有十二长生
                    ctx.beginPath()
                    ctx.arc(x, y, r + 4 * offset, one * i + one, one * (i + 1) + one)
                    ctx.lineCap = "butt"
                    ctx.lineWidth = 1
                    ctx.lineTo(x + Math.cos(startAngle / 2 + angle * i + angle / 2) * (r + 2 * offset), y + Math.sin(startAngle / 2 + angle * i + angle / 2) * (r + 2 * offset))
                    ctx.stroke()

                    textX = x + Math.cos(startAngle + angle * i) * (r + 1 * offset - little)
                    textY = y + Math.sin(startAngle + angle * i) * (r + 1 * offset - little)
                    ctx.beginPath()
                    ctx.font = fontSize + "px Arial";
                    ctx.textAlign = "center";
                    ctx.textBaseline = "middle";
                    ctx.fillStyle = "black"
                    ctx.fillText(dzArr[i], textX, textY)

                    textX = x + Math.cos(startAngle + angle * i) * (r + 2 * offset - little)
                    textY = y + Math.sin(startAngle + angle * i) * (r + 2 * offset - little)
                    ctx.beginPath()
                    ctx.font = fontSize + "px Arial";
                    ctx.textAlign = "center";
                    ctx.textBaseline = "middle";
                    ctx.fillStyle = wuXingColorArr[wuXingArr.indexOf(dzPArr[tianPanObj.tianPanZhiIndexList[i]])]
                    ctx.fillText(tianPanObj.tianPanZhiNameList[i], textX, textY)

                    var textX = x + Math.cos(startAngle + angle * i + angle / 4) * (r + 3 * offset - little)
                    var textY = y + Math.sin(startAngle + angle * i + angle / 4) * (r + 3 * offset - little)
                    ctx.beginPath()
                    ctx.font = fontSize + "px KaiTi";
                    ctx.textAlign = "center";
                    ctx.textBaseline = "middle";
                    ctx.fillStyle = "#d49139"
                    ctx.fillText(tianPanObj.changShengNameList[i], textX, textY)

                    var textX = x + Math.cos(startAngle + angle * i - angle / 4) * (r + 3 * offset - little)
                    var textY = y + Math.sin(startAngle + angle * i - angle / 4) * (r + 3 * offset - little)
                    ctx.beginPath()
                    ctx.font = fontSize + "px KaiTi";
                    ctx.textAlign = "center";
                    ctx.textBaseline = "middle";
                    ctx.fillStyle = "#2d84a1"
                    ctx.fillText(tianPanObj.wangNameList[i], textX, textY)

                    var textX = x + Math.cos(startAngle + angle * i + angle / 4) * (r + 4 * offset - little)
                    var textY = y + Math.sin(startAngle + angle * i + angle / 4) * (r + 4 * offset - little)
                    ctx.beginPath()
                    ctx.font = littleFontSize + "px KaiTi";
                    ctx.textAlign = "center";
                    ctx.fillStyle = "#9da9ad"
                    ctx.textBaseline = "middle";
                    ctx.fillText(tianPanObj.tianPanMuJiangNameList[i], textX, textY)

                    var textX = x + Math.cos(startAngle + angle * i - angle / 4) * (r + 4 * offset - little)
                    var textY = y + Math.sin(startAngle + angle * i - angle / 4) * (r + 4 * offset - little)
                    ctx.beginPath()
                    ctx.font = fontSize + "px bold KaiTi";
                    ctx.textAlign = "center";
                    ctx.fillStyle = wuXingColorArr[wuXingArr.indexOf(tianJiangPArr[tianPanObj.tianPanJiangIndexList[i]])]
                    ctx.textBaseline = "middle";
                    ctx.fillText(tianPanObj.tianPanJiangNameList[i], textX, textY)
                }
            })

        //运行结束时间
        var end = new Date().getTime();
        log.info('paipan-onShow-runTime-排盘运行时间', (end - start))
    },
    onHide: function () {
    },
    onReady: function () {
    },
    //普通弹窗
    diytoast: function (text) {
        this.shaDialog.hide();
        this.dialog.show(text);
    },
    //神煞弹窗
    diyShaToast: function (text) {
        this.dialog.hide();
        this.shaDialog.show(text);
    },
    //点击神煞切换内容
    changeToastContent: function (text) {
        this.shaDialog.changeToastContent(text);
    },
    //圆形点击事件
    start(e) {
        this.setData({
            x: e.touches[0].x,
            y: e.touches[0].y
        })

        var tianPanObj = this.tianPanObj
        var tianPanJiangIndexList = tianPanObj.tianPanJiangIndexList
        var tianPanJiangNameList = tianPanObj.tianPanJiangNameList
        var tianPanMuJiangIndexList = tianPanObj.tianPanMuJiangIndexList
        var tianPanMuJiangNameList = tianPanObj.tianPanMuJiangNameList
        var tianPanZhiIndexList = tianPanObj.tianPanZhiIndexList
        var tianPanZhiNameList = tianPanObj.tianPanZhiNameList
        var wangIndexList = tianPanObj.wangIndexList
        var wangNameList = tianPanObj.wangNameList
        var changShengIndexList = tianPanObj.changShengIndexList
        var changShengNameList = tianPanObj.changShengNameList

        var xO = this.widthO / 2
        var yO = this.heightO / 2
        var rO = this.rO
        var fO = this.fO
        var xV = e.touches[0].x
        var yV = e.touches[0].y
        var absX = Math.abs(xV - xO)
        var absY = Math.abs(yV - yO)

        var xOff = xV - xO
        var yOff = yV - yO
        //坐标到圆心的距离
        var len = Math.sqrt(absX * absX + absY * absY)
        //计算当前角度值       
        var tan = absX / absY;
        var tanAngle = Math.round(Math.atan(tan) * 180 / Math.PI)

        //象限数字
        var xiangNum = 0
        //按照360的顺序来算
        var realAngle = 0

        //确定象限
        if (xOff > 0 && yOff > 0) {
            xiangNum = 3
            //realAngle = xiangNum * 90 + tanAngle
            realAngle = xiangNum * 90 + 90 - tanAngle
        } else if (xOff < 0 && yOff < 0) {
            xiangNum = 1
            //realAngle = xiangNum * 90 + tanAngle
            realAngle = xiangNum * 90 + 90 - tanAngle
        } else if (xOff > 0 && yOff < 0) {
            xiangNum = 2
            //realAngle = xiangNum * 90 + 90 - tanAngle
            realAngle = xiangNum * 90 + tanAngle
        } else if (xOff < 0 && yOff > 0) {
            xiangNum = 0
            //realAngle = xiangNum * 90 + 90 - tanAngle
            realAngle = tanAngle
        }

        //对应地盘上面的地支
        var angleIndex = Math.round(Math.floor(realAngle / 15) / 2) % 12
        var halfAngleIndex = Math.round(Math.floor(realAngle / 15)) % 24

        //地盘
        if (len > rO && len < rO + fO) {
            //月将从亥开始
            this.diyShaToast(this.getAllShaListByZhiName(angleIndex))
        }
        //天盘
        else if (len > rO + fO && len < rO + 2 * fO) {
            //月将从亥开始
            this.diytoast(yueJiangDesc[11 - dzArr.indexOf(tianPanZhiNameList[angleIndex])])
        }
        //旺、长生
        else if (len > rO + 2 * fO && len < rO + 3 * fO) {
            //var showName = halfAngleIndex % 2 == 0 ? changShengNameList[angleIndex] : wangNameList[angleIndex]
            var showName = changShengNameList[angleIndex]
            this.diytoast(changShengDesc[changShengArr.indexOf(showName)])
        }
        //天将、幕将
        else if (len > rO + 3 * fO && len < rO + 4 * fO) {
            var showName = halfAngleIndex % 2 == 0 ? tianPanMuJiangNameList[angleIndex] : tianPanJiangNameList[angleIndex]
            this.diytoast(tianJiangDesc[tianJiangArr.indexOf(showName)])
        }
    },
    move(e) {
        this.setData({
            x: e.touches[0].x,
            y: e.touches[0].y
        })
    },
    end(e) {

    },
    //获取时间相关并展示
    getTimeData: function (nowDate, longitude) {
        //输入时间，经纬度编码
        var ob = sizhu.getSiZhu(nowDate, longitude)

        //获取天干地支所有信息
        this.getTimeList(ob)

        //获取活时地支
        this.getHuoShi(ob)

        //获取行年本命
        this.getNianMing(ob)

        //获取旬空
        this.getEmptyList(ob)

        //获取旬首
        this.getXunShou(ob)

        //打印ob对象
        log.info('paipan-getTimeData-四柱、旬空和真太阳', ob)
        log.addFilterMsg('getTimeData')

        //页面赋值
        this.setData({
            week: util.getWeekByDate(nowDate),
            solarTime: util.formatTime(nowDate),
            //农历月、日
            yearL: ob.bz_jn,
            monthL: ob.bz_jy,
            dayL: ob.bz_jr,
            hourL: ob.bz_js,
            xingNianName: dzArr[ob.xingNianZhi],
            benMingName: dzArr[ob.benMingZhi],
            xunKongValue: ob.xunKongList[2],
            xunShouZhi: "(甲" + dzArr[ob.xunShouZhi] + " 癸" + dzArr[ob.xunWeiZhi] + ")",
            huoShiHidden : ob.huoShiHidden,
            huoShiValue : dzArr[ob.huoShiHour],
            lunarDate: ob.newmonth + '月' + ob.newday
        })
        return ob
    },
    //获取年月日时天干地支名称、干支下标
    getTimeList: function (ob) {
        //获取当前时间的天干地支名称和下标
        var yearGanZhiName = ob.bz_jn
        var monthGanZhiName = ob.bz_jy
        var dayGanZhiName = ob.bz_jr
        var hourGanZhiName = ob.bz_js

        var yearGanName = yearGanZhiName.substr(0, 1)
        var yearZhiName = yearGanZhiName.substr(1)
        var yearGanIndex = tgArr.indexOf(yearGanName)
        var yearZhiIndex = dzArr.indexOf(yearZhiName)
        var yearGanWxName = tgPArr[yearGanIndex]
        var yearGanWxIndex = wuXingArr.indexOf(yearGanWxName)
        var yearZhiWxName = dzPArr[yearZhiIndex]
        var yearZhiWxIndex = wuXingArr.indexOf(yearZhiWxName)

        var monthGanName = monthGanZhiName.substr(0, 1)
        var monthZhiName = monthGanZhiName.substr(1)
        var monthGanIndex = tgArr.indexOf(monthGanName)
        var monthZhiIndex = dzArr.indexOf(monthZhiName)
        var monthGanWxName = tgPArr[monthGanIndex]
        var monthGanWxIndex = wuXingArr.indexOf(monthGanWxName)
        var monthZhiWxName = dzPArr[monthZhiIndex]
        var monthZhiWxIndex = wuXingArr.indexOf(monthZhiWxName)

        var dayGanName = dayGanZhiName.substr(0, 1)
        var dayZhiName = dayGanZhiName.substr(1)
        var dayGanIndex = tgArr.indexOf(dayGanName)
        var dayZhiIndex = dzArr.indexOf(dayZhiName)
        var dayGanWxName = tgPArr[dayGanIndex]
        var dayGanWxIndex = wuXingArr.indexOf(dayGanWxName)
        var dayZhiWxName = dzPArr[dayZhiIndex]
        var dayZhiWxIndex = wuXingArr.indexOf(dayZhiWxName)

        var hourGanName = hourGanZhiName.substr(0, 1)
        var hourZhiName = hourGanZhiName.substr(1)
        var hourGanIndex = tgArr.indexOf(hourGanName)
        var hourZhiIndex = dzArr.indexOf(hourZhiName)
        var hourGanWxName = tgPArr[hourGanIndex]
        var hourGanWxIndex = wuXingArr.indexOf(hourGanWxName)
        var hourZhiWxName = dzPArr[hourZhiIndex]
        var hourZhiWxIndex = wuXingArr.indexOf(hourZhiWxName)

        //存储天干的阴阳，以后用处特别多
        var dayGanYy = dayGanIndex % 2

        //封装数据
        var timeGanNameList = [yearGanName, monthGanName, dayGanName, hourGanName]
        var timeZhiNameList = [yearZhiName, monthZhiName, dayZhiName, hourZhiName]
        var timeGanIndexList = [yearGanIndex, monthGanIndex, dayGanIndex, hourGanIndex]
        var timeZhiIndexList = [yearZhiIndex, monthZhiIndex, dayZhiIndex, hourZhiIndex]
        var timeGanWxNameList = [yearGanWxName, monthGanWxName, dayGanWxName, hourGanWxName]
        var timeGanWxIndexList = [yearGanWxIndex, monthGanWxIndex, dayGanWxIndex, hourGanWxIndex]
        var timeZhiWxNameList = [yearZhiWxName, monthZhiWxName, dayZhiWxName, hourZhiWxName]
        var timeZhiWxIndexList = [yearZhiWxIndex, monthZhiWxIndex, dayZhiWxIndex, hourZhiWxIndex]

        //封装到ob中，到时候直接取
        ob.yearGanName = yearGanName
        ob.yearZhiName = yearZhiName
        ob.yearGanIndex = yearGanIndex
        ob.yearZhiIndex = yearZhiIndex
        ob.yearGanWxName = yearGanWxName
        ob.yearGanWxIndex = yearGanWxIndex
        ob.yearZhiWxName = yearZhiWxName
        ob.yearZhiWxIndex = yearZhiWxIndex

        ob.monthGanName = monthGanName
        ob.monthZhiName = monthZhiName
        ob.monthGanIndex = monthGanIndex
        ob.monthZhiIndex = monthZhiIndex
        ob.monthGanWxName = monthGanWxName
        ob.monthGanWxIndex = monthGanWxIndex
        ob.monthZhiWxName = monthZhiWxName
        ob.monthZhiWxIndex = monthZhiWxIndex

        ob.dayGanName = dayGanName
        ob.dayZhiName = dayZhiName
        ob.dayGanIndex = dayGanIndex
        ob.dayZhiIndex = dayZhiIndex
        ob.dayGanWxName = dayGanWxName
        ob.dayGanWxIndex = dayGanWxIndex
        ob.dayZhiWxName = dayZhiWxName
        ob.dayZhiWxIndex = dayZhiWxIndex

        ob.hourGanName = hourGanName
        ob.hourZhiName = hourZhiName
        ob.hourGanIndex = hourGanIndex
        ob.hourZhiIndex = hourZhiIndex
        ob.hourGanWxName = hourGanWxName
        ob.hourGanWxIndex = hourGanWxIndex
        ob.hourZhiWxName = hourZhiWxName
        ob.hourZhiWxIndex = hourZhiWxIndex

        //日干阴阳，用得比较多
        ob.dayGanYy = dayGanYy

        //封装成List
        ob.timeGanNameList = timeGanNameList
        ob.timeZhiNameList = timeZhiNameList
        ob.timeGanIndexList = timeGanIndexList
        ob.timeZhiIndexList = timeZhiIndexList
        ob.timeGanWxNameList = timeGanWxNameList
        ob.timeGanWxIndexList = timeGanWxIndexList
        ob.timeZhiWxNameList = timeZhiWxNameList
        ob.timeZhiWxIndexList = timeZhiWxIndexList

        this.yearZhiIndex = yearZhiIndex
        this.monthZhiIndex = monthZhiIndex
        this.dayGanIndex = dayGanIndex
        this.dayZhiIndex = dayZhiIndex

        console.log("打印当前天干地支所有信息");
        console.log(ob);
    },
    //获取活时地支
    getHuoShi: function (ob) {
        var switchVal  = app.globalData.switch
        var hour = app.globalData.hour
      
        ob.huoShiHidden = switchVal ? false : true

        ob.huoShiHour = hour
    },
    //获取行年本命
    getNianMing: function (ob) {
        var gender = app.globalData.gender
        var birthday = app.globalData.birthday

        var date = new Date()
        //获取当前的年分的地支
        var nianZhi = (date.getFullYear() - 4)  % 12

        //本命支
        var benMingZhi = (birthday - 4) % 12

        //行年
        var xingNianZhi = 0

        if (gender == 0) {
            xingNianZhi = (2 + (nianZhi + 12 - benMingZhi) % 12) % 12
        } else if (gender == 1) {
            xingNianZhi = (20 - (nianZhi + 12 - benMingZhi) % 12) % 12
        }
        //赋值
        ob.benMingZhi = benMingZhi
        ob.xingNianZhi = xingNianZhi
    },
    //获取年月日时旬空列表
    getEmptyList: function (ob) {
        //获取旬空，根据天干地支计算，由 n =（地支 - 天干 - 1） % 12 - 1，即可得到旬空，即为 n、n+1
        //封装旬空的列表
        var xunKongList = new Array(4)

        for (var i = 0; i < 4; i++) {
            xunKongList[i] = this.getXunKong(ob.timeGanIndexList[i], ob.timeZhiIndexList[i])
        }

        //封装旬空到ob中
        ob.xunKongList = xunKongList
    },
    //获取旬空方法
    getXunKong: function (ganIndex, zhiIndex) {
        var xunKongObj = new Object()

        //获取旬空地支的下标
        var kongOneIndex = (zhiIndex - ganIndex + 10) % 12
        var kongTwoIndex = kongOneIndex + 1

        //获取旬空地支的名称
        var kongOneName = dzArr[kongOneIndex]
        var kongTwoName = dzArr[kongTwoIndex]

        //封装旬空的下标和名称
        xunKongObj.kongOneIndex = kongOneIndex
        xunKongObj.kongTwoIndex = kongTwoIndex
        xunKongObj.kongOneName = kongOneName
        xunKongObj.kongTwoName = kongTwoName
        return xunKongObj
    },
    //获取孟仲季排序数字
    getMengZhongNum: function (diZhiIndex) {
        if (diZhiIndex % 3 == 2) {//孟
            return 3
        } else if (diZhiIndex % 3 == 0) {//仲
            return 2
        } else {//不取季
            return 0
        }
    },
    //获取天将盘List
    getTianPanList: function (nowDate, ob) {
        //获取当前年
        var year = nowDate.getFullYear()
        //获取节气List
        var preJieQiList = sizhu.getJieQi(year - 1)
        //获取节气List
        var currjieQiList = sizhu.getJieQi(year)
        //防止出现节气时间不包含当前年的
        var nextJieQiList = sizhu.getJieQi(year + 1)
        //开始节气
        //当前节气在节气List中的下标
        var currJieQiListIndex
        var currJieQiName = ''
        var currJieQiDate
        //下一个节气
        var nextJieQiListIndex
        var nextJieQiName = ''
        var nextJieQiDate
        //月将下标
        var yueJiangZhiIndex
        //月将地支
        var yueJiangZhiName
        //月将名称
        var yueJiangName
        //定义节气
        var jieQiList = []

        //将三年内的节气都存放到jieQiList中
        jieQiList = preJieQiList.concat(currjieQiList).concat(nextJieQiList)

        //将三年内的节气都包含到列表中，肯定有一个大于当前年，且下标 > 0
        for (var i = 0; i < jieQiList.length; i++) {
            //如果时间大于某一个，则停止
            if (jieQiList[i].date.getTime() > nowDate.getTime()) {
                //如果获取的i大于0.则前一个则是当前节气，如果等于0.则最后一个是当前节气
                currJieQiListIndex = i - 1
                break
            }
        }
        console.log("打印当前节气所有数据", jieQiList);
        console.log("打印当前下标" + currJieQiListIndex);

        //通过下标获取当前节气名和时间
        currJieQiName = jieQiList[currJieQiListIndex].jieQi
        currJieQiDate = jieQiList[currJieQiListIndex].date
        //获取下一个节气的名称和时间
        nextJieQiListIndex = (currJieQiListIndex + 1) % 24
        nextJieQiName = jieQiList[nextJieQiListIndex].jieQi
        nextJieQiDate = jieQiList[nextJieQiListIndex].date

        //获取当前节气在jieQiArr中的下标，通过下标获取月将
        var currJieQiArrIndex = jieQiArr.indexOf(currJieQiName)

        //获取具体的对应index下标, 获取对应月将的地支，例如雨水、惊蛰为0、1，除以二为0，反向11 -0 ，11对应的地支亥
        //例如大寒、立春对应的是 22、23，除以二为11，反向 11 -11，0对应的地支是子
        yueJiangZhiIndex = 11 - Math.floor(currJieQiArrIndex / 2)
        yueJiangZhiName = dzArr[yueJiangZhiIndex]
        yueJiangName = yueJiangArr[yueJiangZhiIndex]

        console.log("月将下标" + yueJiangZhiIndex);
        console.log("月将地支" + yueJiangZhiName);
        console.log("月将名称" + yueJiangName)

        //用当前月将的值减去时间的地支，则为天盘合地盘的差值

        //这里需要注意活时起课，时间则不一样
        var hourZhiIndex
        //这里需要注意，如果活时间起课，则使用活时的时间
        var switchVal  = app.globalData.switch
        var hour = app.globalData.hour
        if(switchVal){
            hourZhiIndex = hour
        }else{
            hourZhiIndex = ob.hourZhiIndex
        }

        var tianDiOffset = (yueJiangZhiIndex - hourZhiIndex + 12) % 12
        console.log("当前时间天盘合地盘差值-最终结果: " + tianDiOffset);
        this.tianDiOffset = tianDiOffset

        //存放的list
        var tianPanObj = new Object()

        //天盘地支名称list
        var tianPanZhiNameList = []
        //天盘地支下标list
        var tianPanZhiIndexList = []
        //获取地盘地支五行下标list
        var diPanZhiWxIndexList = []
        //获取地盘支寄宫干的五行下标list
        var diPanZhiJiGongWxIndexList = []
        //获取月将名称list
        var yueJiangNameList = []
        //获取孟仲季下标list
        var mengZhongJiIndexList = []
        //获取天盘ObjList
        var tianPanObjList = []

        for (var i = 0; i < 12; i++) {
            //获取差值对应的地支下标
            var tianPanZhiIndex = (tianDiOffset + i) % 12
            //地盘孟仲季列表，孟仲季是根据地盘的方位来的，最终取值是取天盘的地支
            //孟 % 3 == 2，仲 % 3 = 0， 季 % 3 = 1,那么数字则改为 3, 2, 0
            mengZhongJiIndexList[i] = this.getMengZhongNum(i)
            //存储支对应的天干list，寄宫是取的地盘的地支的寄宫，这里取的是天干的index
            var jiGongGanIndexList = tlvJiGongZhiArr[i]
            //存储对应天干的五行
            var jiGongGanWxIndexList = new Array()
            for (var n = 0; n < jiGongGanIndexList.length; n++) {
                //通过寄宫的数组，获取寄宫的地支五行，然后获取五行的index，然后将其存放到jiGongGanWxList
                jiGongGanWxIndexList.push(wuXingArr.indexOf(tgPArr[jiGongGanIndexList[n]]))
            }

            //获取地支五行，获取地盘的地支五行index
            diPanZhiWxIndexList.push(wuXingArr.indexOf(dzPArr[i]))

            //获取地支寄宫的五行，二维数组
            diPanZhiJiGongWxIndexList.push(jiGongGanWxIndexList)

            //获取月将List
            yueJiangNameList.push(yueJiangArr[tianPanZhiIndex])

            //天盘的地支合天盘的名称
            tianPanZhiIndexList.push(tianPanZhiIndex)
            tianPanZhiNameList.push(dzArr[tianPanZhiIndex])

            //保存天盘的地支、地址名称、月将
            var obj = new Object()
            obj.diZhi = tianPanZhiIndex
            obj.diZhiName = dzArr[tianPanZhiIndex]
            obj.yueJiangName = yueJiangArr[tianPanZhiIndex]

            //封装天盘ObjList对象
            tianPanObjList.push(obj)
        }

        //判断伏吟和反吟
        //menType 伏吟为80，反吟为90，驿马为91
        var menType = 0
        var yinType = 0
        if (tianPanZhiIndexList[0] == 0) {
            menType = 80
            yinType = 1
        } else if (tianPanZhiIndexList[0] == 6) {
            menType = 90
            yinType = 2

            //这里95就是驿马类型的
            if (yiMaArr.indexOf([ob.dayGanIndex, ob.dayZhiIndex]) > -1) {
                menType = 95
            }
        }

        console.log("打印天盘List");
        console.log(tianPanObjList);
        console.log("打印天盘名称List" + tianPanZhiNameList);

        tianPanObj.menType = menType
        tianPanObj.yinType = yinType
        tianPanObj.mengZhongJiIndexList = mengZhongJiIndexList
        tianPanObj.tianPanZhiIndexList = tianPanZhiIndexList
        tianPanObj.tianPanZhiNameList = tianPanZhiNameList
        tianPanObj.diPanZhiWxIndexList = diPanZhiWxIndexList
        tianPanObj.diPanZhiJiGongWxIndexList = diPanZhiJiGongWxIndexList
        tianPanObj.yueJiangNameList = yueJiangNameList
        tianPanObj.tianPanObjList = tianPanObjList

        //封装数据
        tianPanObj.tianDiOffset = tianDiOffset
        tianPanObj.yueJiangZhiIndex = yueJiangZhiIndex
        tianPanObj.yueJiangZhiName = yueJiangZhiName
        tianPanObj.yueJiangName = yueJiangName

        tianPanObj.currJieQiName = currJieQiName
        tianPanObj.currJieQiDate = currJieQiDate
        tianPanObj.nextJieQiName = nextJieQiName
        tianPanObj.nextJieQiDate = nextJieQiDate

        return tianPanObj
    },
    //获取天将
    getTianJiangList: function (tianPanObj, ob) {
        //获取天盘地支List
        var tianPanZhiIndexList = tianPanObj.tianPanZhiIndexList
        //获取当前日天干
        var dayGanIndex = ob.dayGanIndex
        //获取当前时间地支
        var hourZhiIndex
        //这里需要注意，如果活时间起课，则使用活时的时间
        var switchVal  = app.globalData.switch
        var hour = app.globalData.hour
        if(switchVal){
            hourZhiIndex = hour
        }else{
            hourZhiIndex = ob.hourZhiIndex
        }

        //type为昼夜区分，0：白昼，1：夜晚
        var zhouYeType = 0
        //昼夜是区分是根据占时来的
        if (hourZhiIndex > 2 && hourZhiIndex < 9) {
            zhouYeType = 0
        } else if (hourZhiIndex > 8 || hourZhiIndex < 3) {
            zhouYeType = 1
        }

        tianPanObj.zhouYeType = zhouYeType

        this.getTianJiangByType(tianPanObj, tianPanZhiIndexList, dayGanIndex, 0, zhouYeType)
        this.getTianJiangByType(tianPanObj, tianPanZhiIndexList, dayGanIndex, 1, zhouYeType)
    },
    //获取昼夜天将
    getTianJiangByType: function (tianPanObj, tianPanZhiIndexList, dayGanIndex, type, zhouYeType) {
        //获取对应下标的地支，这个是地盘的下标
        var guiDiZhiIndex = tianJiangRule[type][dayGanIndex]
        console.log("打印贵人所在的地支下标" + guiDiZhiIndex);

        //获取贵人在天盘地支的位置，此下标位置也是实际的位置，也就是天盘哪个地支的贵人的具体地盘位置，以这个来判断具体的方位
        var guiTianZhiIndex = tianPanZhiIndexList.indexOf(guiDiZhiIndex)
        console.log("打印贵人在天盘地支上的位置" + guiTianZhiIndex);

        //根据贵人的地支方位来确定顺排合逆排序
        var ascFlag = true
        //判断是否顺排或者逆排
        if (guiTianZhiIndex == 11 || guiTianZhiIndex < 5) {
            ascFlag = true
        } else if (guiTianZhiIndex > 4 && guiTianZhiIndex < 11) {
            ascFlag = false
        }
        console.log("打印贵人顺序ascFlag" + ascFlag);

        //获取昼夜贵人
        var tianPanJiangIndexList = []
        var tianPanJiangNameList = []

        //顺排合逆排的下标不一样
        //顺排合逆排

        //获取子地支时候的天将
        for (var i = 0; i < tianJiangArr.length; i++) {
            //第一个贵人的名称，赋值给地盘上的坐标
            tianPanJiangNameList[(guiTianZhiIndex + i) % 12] = tianJiangArr[i]

            //大于0则顺序根据ascFlag排列
            if (i > 0) {
                tianPanJiangNameList[(guiTianZhiIndex + i) % 12] = tianJiangArr[ascFlag ? i : 12 - i]
            }

            //同理下标也是这样来的
            tianPanJiangIndexList[(guiTianZhiIndex + i) % 12] = tianJiangArr.indexOf(tianPanJiangNameList[(guiTianZhiIndex + i) % 12])
        }

        //封裝所有数据到tianPanObj中
        for (var n = 0; n < tianPanJiangIndexList.length; n++) {
            tianPanObj.tianPanObjList[n].tianJiangIndex = tianPanJiangIndexList[n]
            tianPanObj.tianPanObjList[n].tianJiangName = tianJiangArr[tianPanJiangIndexList[n]]
        }

        if (zhouYeType == type) {
            tianPanObj.tianPanJiangIndexList = tianPanJiangIndexList
            tianPanObj.tianPanJiangNameList = tianPanJiangNameList
        } if (zhouYeType != type) {
            tianPanObj.tianPanMuJiangIndexList = tianPanJiangIndexList
            tianPanObj.tianPanMuJiangNameList = tianPanJiangNameList
        }
    },
    //获取四课
    getFourLesson: function (tianPanObj, ob) {
        var tianPanZhiIndexList = tianPanObj.tianPanZhiIndexList
        var wangNameList = tianPanObj.wangNameList
        var changShengNameList = tianPanObj.changShengNameList

        //第一课
        var lesson1 = this.getLesson(tianPanObj, ob.dayGanIndex, 0)
        var lesson2 = this.getLesson(tianPanObj, tianPanObj.tianPanZhiIndexList[tlvJiGongGanArr[ob.dayGanIndex]], 1)

        //第二课
        var lesson3 = this.getLesson(tianPanObj, lesson2.index, 1)
        var lesson4 = this.getLesson(tianPanObj, tianPanObj.tianPanZhiIndexList[lesson3.index], 1)

        //第三课
        var lesson5 = this.getLesson(tianPanObj, ob.dayZhiIndex, 1)
        var lesson6 = this.getLesson(tianPanObj, tianPanObj.tianPanZhiIndexList[lesson5.index], 1)

        //第四课
        var lesson7 = this.getLesson(tianPanObj, lesson6.index, 1)
        var lesson8 = this.getLesson(tianPanObj, tianPanObj.tianPanZhiIndexList[lesson7.index], 1)

        var fourLessonList = [lesson1, lesson2, lesson3, lesson4, lesson5, lesson6, lesson7, lesson8]
        console.log("打印四课数据");
        console.log(fourLessonList);

        //将fourLessonList变成上下两个list
        var fourLessonShowList = []
        var fourLessonShowObj
        for (var i = 0; i < 4; i++) {
            fourLessonShowObj = new Object()
            fourLessonShowObj.upIndex = fourLessonList[2 * i + 1].index
            fourLessonShowObj.dwIndex = fourLessonList[2 * i].index
            fourLessonShowObj.upName = fourLessonList[2 * i + 1].name
            fourLessonShowObj.dwName = fourLessonList[2 * i].name

            //赋值地支颜色
            fourLessonShowObj.upColor = wuXingColorArr[wuXingArr.indexOf(dzPArr[fourLessonShowObj.upIndex])]
            fourLessonShowObj.dwColor = wuXingColorArr[wuXingArr.indexOf(dzPArr[fourLessonShowObj.dwIndex])]

            fourLessonShowObj.upWang = wangNameList[tianPanZhiIndexList.indexOf(fourLessonList[2 * i + 1].index)]
            fourLessonShowObj.upChangSheng = changShengNameList[tianPanZhiIndexList.indexOf(fourLessonList[2 * i + 1].index)]
            fourLessonShowObj.dwWang = wangNameList[tianPanZhiIndexList.indexOf(fourLessonList[2 * i].index)]
            fourLessonShowObj.dwChangSheng = changShengNameList[tianPanZhiIndexList.indexOf(fourLessonList[2 * i].index)]

            //对日干特殊处理
            if (i == 0) {
                fourLessonShowObj.dwWang = this.getWang(ob, ob.dayGanWxIndex)
                fourLessonShowObj.dwChangSheng = ''
                fourLessonShowObj.dwColor = wuXingColorArr[wuXingArr.indexOf(tgPArr[fourLessonShowObj.dwIndex])]
            }

            fourLessonShowObj.upWxIndex = fourLessonList[2 * i + 1].wxIndex
            fourLessonShowObj.dwWxIndex = fourLessonList[2 * i].wxIndex
            fourLessonShowObj.upYyIndex = fourLessonList[2 * i + 1].yyIndex
            fourLessonShowObj.dwYyIndex = fourLessonList[2 * i].yyIndex
            fourLessonShowObj.upJiangName = fourLessonList[2 * i + 1].tianJiangName
            fourLessonShowObj.dwJiangName = fourLessonList[2 * i].tianJiangName

            //赋值天将颜色
            fourLessonShowObj.upJiangColor = wuXingColorArr[wuXingArr.indexOf(tianJiangPArr[tianJiangArr.indexOf(fourLessonShowObj.upJiangName)])]

            fourLessonShowObj.upMuJiangIndex = fourLessonList[2 * i + 1].tianMuJiangIndex
            fourLessonShowObj.upMuJiangName = fourLessonList[2 * i + 1].tianMuJiangName

            fourLessonShowList.push(fourLessonShowObj)
        }

        //定义干上神
        var ganUpShen = fourLessonList[1].index
        //定义支上神
        var zhiUpShen = fourLessonList[5].index

        //获取日干的阴阳
        var dayGanYy = ob.dayGanYy
        //获取贼list、克list、遥贼list、遥克list、比合list
        //定义贼为-1，克为1，无克为0
        var zeiKeList = []
        //遥克，贼为-1，克为1，无克为0
        var yaoKeList = []
        //比合的课上的下标，比合为1，不比合为0
        var biHeList = []
        //是否四课具备
        var upList = []
        //获取贼克个数，获取遥克个数
        var zeiNumList = [], keNumList = []
        var zeiYNumList = [], keYNumList = []
        var menType = tianPanObj.menType //别则 60， 八专 70
        var yinType = tianPanObj.yinType

        var bieZeBaZhuanType = 0

        for (var i = 0; i < 4; i++) {
            zeiKeList[i] = this.getWuXingKe(fourLessonList[2 * i].wxIndex, fourLessonList[2 * i + 1].wxIndex)
            if (i == 0) {
                yaoKeList[i] = 0
            }
            yaoKeList[i] = this.getWuXingKe(ob.dayGanWxIndex, fourLessonList[2 * i + 1].wxIndex)
            biHeList[i] = ob.dayGanYy == fourLessonList[2 * i + 1].yyIndex ? 1 : 0
            upList[i] = fourLessonList[2 * i + 1].index
        }

        //判断是否四课具备，这个是别则法
        if (upList[0] == upList[3] || upList[1] == upList[2]) {
            bieZeBaZhuanType = 60
        }
        //八专
        if (upList[0] == upList[2] && upList[1] == upList[3]) {
            bieZeBaZhuanType = 70
        }


        if (yinType == 0 && (upList[0] == upList[3] || upList[1] == upList[2])) {
            menType = 60
        }
        //八专
        if (yinType == 0 && upList[0] == upList[2] && upList[1] == upList[3]) {
            menType = 70
        }

        //特殊定义别责、八专类别
        tianPanObj.bieZeBaZhuanType = bieZeBaZhuanType

        //存储有贼克的下标
        for (var i = 0; i < 4; i++) {
            //贼克list存储数据
            if (zeiKeList[i] == -1) {
                zeiNumList.push(i)
            } else if (zeiKeList[i] == 1) {
                keNumList.push(i)
            }

            //遥克存储数据
            if (yaoKeList[i] == -1) {
                zeiYNumList.push(i)
            } else if (yaoKeList[i] == 1) {
                keYNumList.push(i)
            }
        }

        //判断详细的menType
        //如果menType < 80，则不是反吟或者伏吟
        if (menType < 80 && zeiNumList.length == 1) {//始入或者重审
            menType = 10
        } else if (menType < 80 && zeiNumList.length == 0 && keNumList.length == 1) {//元首
            menType = 15
        } else if (menType < 80 && zeiNumList.length > 1) {//比用
            menType = 20
        } else if (menType < 80 && zeiNumList.length == 0 && keNumList.length > 1) {//比用，知一
            menType = 25
        } else if (menType < 70 && zeiNumList.length == 0 && keNumList.length == 0 && (keYNumList.length > 0 || zeiYNumList.length > 0)) {//遥克，这里注意，八专不取遥克
            if (keYNumList.length > 0) { //蒿矢格，上神克日
                menType = 40
            } else if (keYNumList.length == 0 && zeiYNumList.length > 0) {//弹射格，日克上神
                menType = 45
            }
        } else if (menType == 0 && zeiNumList.length == 0 && keNumList.length == 0 && keYNumList.length == 0 && zeiYNumList.length == 0) {//昴星
            //昴星法，阳日取地盘酉上之神为初传、支上之神为中传、干上之神为末传/ 阴日取天盘酉下之神 干上之神为中传  支上之神为末传
            if (dayGanYy == 0) {//虎视格
                menType = 50
            } else if (dayGanYy == 1) {//冬蛇掩目格
                menType = 55
            }
        } else if (yinType == 0 && menType == 60 && zeiNumList.length == 0 && keNumList.length == 0 && keYNumList.length == 0 && zeiYNumList.length == 0) {//别则
            if (dayGanYy == 0) {//阳日取干合之上神为初传，中末都取天干上神
                menType = 60
            } else if (dayGanYy == 1) {//阴日取支前三合为初传，中末都取天干上神
                menType = 65
            }
        } else if (yinType == 0 && menType == 70 && zeiNumList.length == 0 && keNumList.length == 0) {//八专，不取遥克
            //八专法，干支重复，先看又没有克，阳日取上1课神三顺，阴日取4课上神三逆，中末都取天干上神
            if (dayGanYy == 0) {
                menType = 70
            } else if (dayGanYy == 1) {
                menType = 75
            }
        } else if (menType == 80 || yinType == 0) {//伏吟，有克先取克，无克再断阴阳
            if (zeiNumList.length > 0 || keNumList.length > 0) {
                menType = 80
            } else if (zeiNumList.length == 0 && keNumList.length == 0) {
                if (dayGanYy == 0) {
                    menType = 83
                } else if (dayGanYy == 1) {
                    menType = 86
                }
            }
        } else if (menType == 90 || yinType == 1) {//反吟，有克先取克，无克取驿马
            if (zeiNumList.length > 0 || keNumList.length > 0) {
                menType = 90
            } else if (zeiNumList.length == 0 && keNumList.length == 0) {
                menType = 95
            }
        }

        //封装数据
        tianPanObj.ganUpShen = ganUpShen
        tianPanObj.zhiUpShen = zhiUpShen
        tianPanObj.fourLessonList = fourLessonList
        tianPanObj.fourLessonShowList = fourLessonShowList
        tianPanObj.menType = menType
        tianPanObj.zeiKeList = zeiKeList
        tianPanObj.yaoKeList = yaoKeList
        tianPanObj.biHeList = biHeList
        tianPanObj.upList = upList
        tianPanObj.zeiNumList = zeiNumList
        tianPanObj.keNumList = keNumList
        tianPanObj.zeiYNumList = zeiYNumList
        tianPanObj.keYNumList = keYNumList
    },
    //获取每一课内容
    getLesson: function (tianPanObj, diZhiIndex, ganOrZhi) {
        var lesson = new Object()
        //只针对第一个天干
        if (ganOrZhi == 0) {
            var dayGanIndex = diZhiIndex
            //获取天干的下标
            lesson.index = dayGanIndex
            //获取天干的名称
            lesson.name = tgArr[dayGanIndex]
            //获取天干的五行
            lesson.wxIndex = wuXingArr.indexOf(tgPArr[dayGanIndex])
            //获取天干的阴阳
            lesson.yyIndex = dayGanIndex % 2
        } else {
            lesson.index = diZhiIndex
            lesson.name = dzArr[diZhiIndex]
            lesson.wxIndex = wuXingArr.indexOf(dzPArr[diZhiIndex])
            lesson.yyIndex = diZhiIndex % 2

            lesson.tianZhiIndex = tianPanObj.tianPanZhiIndexList.indexOf(diZhiIndex)
            lesson.tianJiangName = tianPanObj.tianPanJiangNameList[lesson.tianZhiIndex]
            lesson.tianMuJiangName = tianPanObj.tianPanMuJiangNameList[lesson.tianZhiIndex]
        }
        return lesson
    },
    //判断是否有贼克、遥克、比合、涉害方法汇总
    getZeiKeChuChuan: function (tianPanObj) {
        var fourLessonList = tianPanObj.fourLessonList
        var menType = tianPanObj.menType
        var biHeList = tianPanObj.biHeList
        var zeiNumList = tianPanObj.zeiNumList
        var keNumList = tianPanObj.keNumList
        var zeiYNumList = tianPanObj.zeiYNumList
        var keYNumList = tianPanObj.keYNumList

        //将贼克、遥贼克统一到一个list中
        var commonZeiKeList
        //初传index
        var procIndex
        //判断是下贼上 -1、上克下 1
        var zeiKeType = 0

        //如果是比用、知一、涉害、遥克、或者是伏吟、反吟的，并且有克的，在这里取初传
        if ((menType >= 10 && menType < 50) || menType == 80 || menType == 90) {

            if (zeiNumList.length == 1) {//始入或者重审
                commonZeiKeList = zeiNumList
            } else if (zeiNumList.length == 0 && keNumList.length == 1) {//元首
                commonZeiKeList = keNumList
            }
            //先取贼为用
            else if (zeiNumList.length > 1) {
                zeiKeType = -1
                commonZeiKeList = zeiNumList
            } else if (zeiNumList.length == 0 && keNumList.length > 1) {//然后就是克
                zeiKeType = 1
                commonZeiKeList = keNumList
            } else if (zeiNumList.length == 0 && keNumList.length == 0 && (keYNumList.length > 0 || zeiYNumList.length > 0)) {//再取遥克
                if (keYNumList.length > 0) { //蒿矢格，上神克日
                    zeiKeType = 1
                    commonZeiKeList = keYNumList
                } else if (keYNumList.length == 0 && zeiYNumList.length > 0) {//弹射格，日克上神
                    zeiKeType = -1
                    commonZeiKeList = zeiYNumList
                }
            }

            console.log("打印commonZeiKeList", commonZeiKeList);

            if (commonZeiKeList.length == 1) {
                procIndex = fourLessonList[2 * commonZeiKeList[0] + 1].index
            } else if (commonZeiKeList.length > 1) {

                console.log("commonZeiKeList", commonZeiKeList);

                //这里commonZeiKeList也要去重一下
                commonZeiKeList = this.getListByBieZeBaZhuan(tianPanObj, commonZeiKeList)

                console.log("commonZeiKeList", commonZeiKeList);

                //如果commonZeiKeList还是1个，则取其中一个的上神，如果大于1，则用比用
                if (commonZeiKeList.length == 1) {
                    procIndex = fourLessonList[2 * commonZeiKeList[0] + 1].index
                } else if (commonZeiKeList.length > 1) {
                    var biHeIndexList = this.getBiHeIndexList(biHeList, commonZeiKeList)
                    tianPanObj.biHeIndexList = biHeIndexList

                    console.log("打印biHeIndexList", biHeIndexList);

                    //判断某课和天干的阴阳相同，则可以知一，否则用涉害
                    if (biHeIndexList.length == 1) {
                        //获取比合唯一的那个课上的地支
                        procIndex = fourLessonList[2 * biHeIndexList[0] + 1].index
                    } else if (biHeIndexList.length > 1) {//这里用到涉害法,比合相同或者都不同
                        procIndex = this.getSheHaiChuChuan(tianPanObj, zeiKeType)
                    }
                }
            }
        }
        return procIndex
    },
    //获取别责和八专三传
    getListByBieZeBaZhuan: function (tianPanObj, list) {

        console.log("打印tianPanObj", tianPanObj);

        var upList = tianPanObj.upList
        var bieZeBaZhuanType = tianPanObj.bieZeBaZhuanType
        //这里去重一下，例如别责和八专情况需要去重
        //别责情况
        if (bieZeBaZhuanType == 60) {
            if (upList[0] == upList[3] && list.indexOf(0) > -1 && list.indexOf(3) > -1) {
                //获取重复值的下标并去除
                list.splice(list.indexOf(0), 1)
            } else if (upList[1] == upList[2] && list.indexOf(1) > -1 && list.indexOf(2) > -1) {
                list.splice(list.indexOf(1), 1)
            }
        } else if (bieZeBaZhuanType == 70) {//八专情况,八专不取遥克
            if (list.indexOf(0) > -1 && list.indexOf(2) > -1) {
                list.splice(list.indexOf(0), 1)
            }
            if (list.indexOf(1) > -1 && list.indexOf(3) > -1) {
                list.splice(list.indexOf(1), 1)
            }
        }
        return list
    },
    //获取三传
    getThreeProcess: function (tianPanObj, ob) {
        var fourLessonList = tianPanObj.fourLessonList
        var tianPanJiangNameList = tianPanObj.tianPanJiangNameList
        var tianPanZhiIndexList = tianPanObj.tianPanZhiIndexList
        var tianPanMuJiangNameList = tianPanObj.tianPanMuJiangNameList


        var qinList = []
        var procList = []
        var jiangList = []

        //获取贼个数，克个数，贼下标、克下标、上下课的五行，还有阴阳
        var threeProcessList = this.getThreeProcessList(fourLessonList, tianPanObj, ob)

        for (var i = 0; i < threeProcessList.length; i++) {
            //页面显示
            qinList.push(sixQinArr[this.getSixQin(threeProcessList[i].procIndex, ob.dayGanIndex)])
            var dunGan = this.getDunGan(threeProcessList[i].procIndex, fourLessonList)
            var procObj = new Object()
            procObj.dunGan = (dunGan != -1) ? tgArr[dunGan] : ""
            if (procObj.dunGan != '') {
                procObj.dunColor = wuXingColorArr[wuXingArr.indexOf(tgPArr[tgArr.indexOf(procObj.dunGan)])]
            }
            procObj.procName = threeProcessList[i].procName
            procObj.procColor = wuXingColorArr[wuXingArr.indexOf(dzPArr[dzArr.indexOf(procObj.procName)])]
            procObj.procWang = threeProcessList[i].procWang
            procObj.procChangSheng = threeProcessList[i].procChangSheng
            procList.push(procObj)

            var jiangObj = new Object()
            jiangObj.jiang = tianPanJiangNameList[tianPanZhiIndexList.indexOf(threeProcessList[i].procIndex)]
            jiangObj.jiangColor = wuXingColorArr[wuXingArr.indexOf(tianJiangPArr[tianJiangArr.indexOf(jiangObj.jiang)])]
            jiangObj.muJiang = tianPanMuJiangNameList[tianPanZhiIndexList.indexOf(threeProcessList[i].procIndex)]
            jiangList.push(jiangObj)

            //存值备用
            threeProcessList[i].dunGan = (dunGan != -1) ? tgArr[dunGan] : ""
            threeProcessList[i].sixQin = sixQinArr[this.getSixQin(threeProcessList[i].procIndex, ob.dayGanIndex)]
            threeProcessList[i].tianJiang = tianPanJiangNameList[tianPanZhiIndexList.indexOf(threeProcessList[i].procIndex)]
            threeProcessList[i].muTianJiang = tianPanMuJiangNameList[tianPanZhiIndexList.indexOf(threeProcessList[i].procIndex)]
        }
        tianPanObj.qinList = qinList
        tianPanObj.procList = procList
        tianPanObj.jiangList = jiangList
        tianPanObj.threeProcessList = threeProcessList

        console.log("打印三传List所有数据");
        console.log(threeProcessList);
    },
    //获取三传List
    getThreeProcessList: function (fourLessonList, tianPanObj, ob) {
        //获取三传
        var threeProcessList = []
        //获取日干的阴阳
        var dayGanYy = ob.dayGanYy
        //获取menType
        var menType = tianPanObj.menType
        //定义初传
        var procIndex

        var ganUpShen = tianPanObj.ganUpShen
        var zhiUpShen = tianPanObj.zhiUpShen

        //定义三传下标list
        var procIndexList = new Array(3)


        if ((menType >= 10 && menType < 50) || menType == 80 || menType == 90) {
            procIndex = this.getZeiKeChuChuan(tianPanObj)
        }

        if (menType >= 10 && menType < 50) { //贼克、比用、涉害、遥克
            var procIndexList = [procIndex, tianPanObj.tianPanZhiIndexList[procIndex], tianPanObj.tianPanZhiIndexList[tianPanObj.tianPanZhiIndexList[procIndex]]]
        }

        if (menType >= 50 && menType < 60) { //昴星
            if (dayGanYy == 0) {//虎视格
                //阳日中传支上神，末传干上神
                procIndexList = [tianPanObj.tianPanZhiIndexList[9], zhiUpShen, ganUpShen]
            } else if (dayGanYy == 1) {//冬蛇掩目格
                //阴日中传干上神，末传支上神
                procIndexList = [tianPanObj.tianPanZhiIndexList.indexOf(9), ganUpShen, zhiUpShen]
            }
        }

        if (menType >= 60 && menType < 70) {//别责
            if (dayGanYy == 0) {//阳日取干合之上神为初传，中末都取天干上神
                var dayHeIndex = (ob.dayGanIndex + 5) % 10
                procIndexList = [tianPanObj.tianPanZhiIndexList[tlvJiGongGanArr[dayHeIndex]], ganUpShen, ganUpShen]
            } else if (dayGanYy == 1) {//阴日取支前三合之上神为初传，中末都取天干上神，//顺时针转6下能够有一个三合的，则是前，不过三合局都是4下，则顺时针进4即为前
                var qianZhiIndex = (tianPanObj.tianPanZhiIndexList.indexOf(ob.dayZhiIndex) + 4) % 12
                procIndexList = [tianPanObj.tianPanZhiIndexList[qianZhiIndex], ganUpShen, ganUpShen]
            }
        }

        if (menType >= 70 && menType < 80) {//八专
            if (dayGanYy == 0) {//阳日取1课上神三顺，中末都取天干上神
                var diZhiTianIndex = tianPanObj.tianPanZhiIndexList.indexOf(ganUpShen)
                procIndexList = [tianPanObj.tianPanZhiIndexList[(diZhiTianIndex + 2) % 12], ganUpShen, ganUpShen]
            } else if (dayGanYy == 1) {////阴日取4课上神三逆，中末都取天干上神
                var diZhiTianIndex = tianPanObj.tianPanZhiIndexList.indexOf(fourLessonList[7].index)
                procIndexList = [tianPanObj.tianPanZhiIndexList[(diZhiTianIndex + 10) % 12], ganUpShen, ganUpShen]
            }
        }

        if (menType >= 80 && menType < 90) {//伏吟，有克用克发用，有克
            var procIndex2
            var procIndex3

            if (menType > 80) {//无克伏吟//阳日取干上神 //阴日支上神
                procIndex = dayGanYy == 0 ? ganUpShen : zhiUpShen
            }

            //判断初传是否自刑，(有克[无论阴阳]和无克阳日取支上神为初传,无克阴日取干上神）
            if (procIndex == xingArr[procIndex]) {
                if (menType > 80) {
                    procIndex2 = dayGanYy == 0 ? zhiUpShen : ganUpShen
                } else if (menType == 80) { //有克自刑取支上神，无论阴阳
                    procIndex2 = zhiUpShen
                }
            } else {
                procIndex2 = xingArr[procIndex]
            }

            //判断中传是否自刑，或者刑后的还是初传
            if (procIndex2 == xingArr[procIndex2] || procIndex == xingArr[procIndex2]) {
                procIndex3 = (procIndex2 + 6) % 12
            } else {
                procIndex3 = xingArr[procIndex2]
            }
            procIndexList = [procIndex, procIndex2, procIndex3]
        }

        if (menType >= 90) {//反吟,有克则取初冲、中冲，无克取驿马，然后取支上神，干上神
            if (menType == 95) {//取驿马，巳酉丑见亥（5，9，1- 11），亥卯未见巳（11，3，7 - 5），寅午戌见申（2，6，10 - 8），申子辰见寅（8，0，4， - 2）
                var fourMa = ob.dayZhiIndex % 4 + (2 - (ob.dayZhiIndex % 4) % 3) * 4
                procIndex = (fourMa + 6) % 12
                procIndexList = [procIndex, zhiUpShen, ganUpShen]
            } else if (menType == 90) {
                procIndexList = [procIndex, (procIndex + 6) % 12, ((procIndex + 6) % 12 + 6) % 12]
            }
        }
        this.getProcByTianPan(tianPanObj, threeProcessList, procIndexList)

        console.log("打印三传List所有数据");
        console.log(threeProcessList);

        //返回三传数据
        return threeProcessList
    },
    //获取五行相克
    getWuXingKe: function (dw, up) {//-1为贼，1为克
        if ((dw + 2) % 5 == up) {
            return -1
        } else if ((dw + 3) % 5 == up) {
            return 1
        } else {
            return 0
        }
    },
    //获取比合相同的课的下标
    getBiHeIndexList: function (biHeList, zeiKeYaoNumList) {
        var biHeIndexList = []
        var buBiHeIndexList = []
        for (var i = 0; i < zeiKeYaoNumList.length; i++) {
            if (biHeList[zeiKeYaoNumList[i]] == 1) {
                biHeIndexList.push(zeiKeYaoNumList[i])
            } else if (biHeList[zeiKeYaoNumList[i]] == 0) {
                buBiHeIndexList.push(zeiKeYaoNumList[i])
            }
        }

        console.log("打印结果biHeIndexList ： ", biHeIndexList)
        return biHeIndexList.length == 0 ? buBiHeIndexList : biHeIndexList
    },
    //获取涉害的初传
    getSheHaiChuChuan: function (tianPanObj, zeiKeType) {

        var ganUpShen = tianPanObj.ganUpShen
        var zhiUpShen = tianPanObj.zhiUpShen
        var fourLessonList = tianPanObj.fourLessonList
        var biHeIndexList = tianPanObj.biHeIndexList

        console.log("打印结果zeiKeType ： ", zeiKeType)

        //存储所有的涉害值数字
        var maxNumList = []
        //存储最大涉害值的数字
        var maxNum = 0
        for (var i = 0; i < biHeIndexList.length; i++) {
            //通过天盘，还有比合相同的地支获取涉害数量
            var num = this.getSheHaiNum(tianPanObj, fourLessonList[2 * biHeIndexList[i] + 1].index, zeiKeType)
            maxNumList.push(num)
            maxNum = num > maxNum ? num : maxNum
        }

        console.log("打印结果maxNum ： ", maxNum)

        //获取涉害最大值的个数，这里的maxTimeList存储的biHeIndexList中的下标，所以如果只有一个，则获取下标即可
        var maxTimeList = []
        for (var i = 0; i < maxNumList.length; i++) {
            if (maxNumList[i] == maxNum) {
                maxTimeList.push(biHeIndexList[i])
            }
        }

        console.log("打印结果maxTimeList ： ", maxTimeList)

        //如果涉害最大数字只有一个
        if (maxTimeList.length == 1) { //这里涉害法起作用了
            return fourLessonList[2 * maxTimeList[0] + 1].index
        } else {
            //如果还是涉害相同，则取孟，如果没有孟，则取仲
            var mengZhongList = []
            //存储最大孟仲季的数字
            var maxNum = 0
            for (var i = 0; i < maxTimeList.length; i++) {
                //获取当前最大值的地支
                var zhi = fourLessonList[2 * maxTimeList[i] + 1].index
                //获取当前地支的孟仲数量，是根据 %3 来取的
                console.log("打印结果mengZhongList ： ", mengZhongList)

                //tianPanObj.tianPanZhiIndexList.indexOf(zhi)这是获取地盘的下标
                var num = tianPanObj.mengZhongJiIndexList[tianPanObj.tianPanZhiIndexList.indexOf(zhi)]
                //存储孟仲的数量
                mengZhongList.push(num)
                maxNum = num > maxNum ? num : maxNum
            }

            console.log("打印结果mengZhongList ： ", mengZhongList)
            console.log("打印结果maxNum ： ", maxNum)

            //获取最大孟仲季数的下标，还是一样获取maxTimeMzList中孟仲的数量
            var maxTimeMzList = []
            for (var i = 0; i < mengZhongList.length; i++) {
                if (mengZhongList[i] == maxNum && maxNum > 0) {
                    maxTimeMzList.push(maxTimeList[i])
                }
            }

            console.log("打印结果maxTimeMzList ： ", maxTimeMzList)

            //只有一个，且最大值是孟仲
            if (maxTimeMzList.length == 1 && maxNum > 0) { //这里就是孟仲了，取其中一个,见机格/察微格
                return fourLessonList[2 * maxTimeMzList[0] + 1].index
            } else if (maxTimeMzList.length > 1 && maxNum > 0) { // 缀瑕格
                //这里需要注意，如果孟仲还是相同，则取干上神为初传
                return ganUpShen
            }
        }
    },
    //获取涉害的数量
    getSheHaiNum: function (tianPanObj, zhi, zeiKeType) {
        //计算从天盘到地盘所有的被克的个数
        var tianPanZhiIndexList = tianPanObj.tianPanZhiIndexList
        //获取当前支在实际地盘的位置
        var tianZhiIndex = tianPanZhiIndexList.indexOf(zhi)
        //获取地支的五行下标
        var zhiWxIndex = wuXingArr.indexOf(dzPArr[zhi])
        //存储克的数量
        var num = 0

        console.log("打印结果tianZhiIndex ： " + tianZhiIndex)
        console.log("打印结果zhiWxIndex ： " + zhiWxIndex)

        //这里需要注意的是，如果是下贼上，那么获取的就是被克的数量
        //如果是上克下，则获取上神克地盘的数量

        //最多12次，一般不会多余12次
        for (var i = 0; i < 12; i++) {
            //i为原始地盘，加上天盘的地支，获取实际位置
            var currIndex = (i + tianZhiIndex) % 12
            //初始化每个地支的wxList
            var wxList = []

            console.log("打印结果currIndex ： ", currIndex)
            console.log("打印结果tianPanObj.diPanZhiWxIndexList ：", tianPanObj.diPanZhiWxIndexList)

            //将当前地支的地支的五行存储到wxList中
            wxList.push(tianPanObj.diPanZhiWxIndexList[currIndex])

            //将当前地支对应的寄宫也存放到wxList中
            console.log("打印结果寄宫五行list ： ", tianPanObj.diPanZhiJiGongWxIndexList[currIndex])
            wxList = wxList.concat(tianPanObj.diPanZhiJiGongWxIndexList[currIndex])

            for (var n = 0; n < wxList.length; n++) {
                //五行list和当前地支的五行比较，如果是-1，则是五行list克当前地支，如果为1，则是当前地支克五行list
                if (this.getWuXingKe(wxList[n], zhiWxIndex) == zeiKeType) {
                    num += 1
                }
            }
            if (currIndex == zhi) {
                break
            }
        }
        return num
    },
    //通过天盘获取三传
    getProcByTianPan: function (tianPanObj, threeProcessList, procIndexList) {
        var tianPanZhiIndexList = tianPanObj.tianPanZhiIndexList
        var wangNameList = tianPanObj.wangNameList
        var changShengNameList = tianPanObj.changShengNameList

        console.log("打印结果procIndexList ： ")
        console.log(procIndexList)

        for (var i = 0; i < 3; i++) {
            var procObj = new Object()
            procObj.procIndex = procIndexList[i]
            procObj.procWang = wangNameList[tianPanZhiIndexList.indexOf(procIndexList[i])]
            procObj.procChangSheng = changShengNameList[tianPanZhiIndexList.indexOf(procIndexList[i])]
            procObj.procName = dzArr[procObj.procIndex]
            threeProcessList.push(procObj)
        }
    },
    //获取遁干
    getDunGan: function (zhi, fourLessonList) {
        var dayGanIndex = fourLessonList[0].index
        var dayZhiIndex = fourLessonList[4].index
        var offset = (dayZhiIndex - dayGanIndex + 12) % 12
        var dunGan = (zhi - offset + 12) % 12
        dunGan = dunGan > 9 ? -1 : dunGan
        return dunGan
    },
    //获取旬首、尾、丁、辛
    getXunShou: function (ob) {
        var dayGanIndex = ob.dayGanIndex
        var dayZhiIndex = ob.dayZhiIndex
        var xunShouZhi = (dayZhiIndex - dayGanIndex + 12) % 12
        ob.xunShouZhi = xunShouZhi
        ob.xunWeiZhi = (xunShouZhi + 9) % 12
        ob.xunDingZhi = (xunShouZhi + 3) % 12
        ob.xunXinZhi = (xunShouZhi + 7) % 12

        this.xunShouZhi = xunShouZhi
        this.xunWeiZhi = (xunShouZhi + 9) % 12
        this.xunDingZhi = (xunShouZhi + 3) % 12
        this.xunXinZhi = (xunShouZhi + 7) % 12

    },
    //获取六亲
    getSixQin: function (zhi, dayGan) {
        var dayGanWx = wuXingArr.indexOf(tgPArr[dayGan])
        var zhiWx = wuXingArr.indexOf(dzPArr[zhi])
        var offset = (zhiWx - dayGanWx + 5) % 5
        return offset
    },
    //获取旺相休囚死
    getWangList: function (tianPanObj, ob) {
        var wangIndexList = []
        var wangNameList = []
        var tianPanZhiIndexList = tianPanObj.tianPanZhiIndexList
        var monthZhiIndex = ob.monthZhiIndex
        var monthZhiWxIndex = ob.monthZhiWxIndex

        for (var i = 0; i < 12; i++) {
            var zhiWxIndex = wuXingArr.indexOf(dzPArr[tianPanZhiIndexList[i]])

            var wangIndex = (5 - (monthZhiWxIndex - zhiWxIndex)) % 5

            //丑月水相，辰月木相，未月火相，戌月金相
            if (monthZhiIndex % 3 == 1) {
                if (monthZhiIndex == 1 && zhiWxIndex == 4) {
                    wangIndex = 1
                }
                else if (monthZhiIndex == 4 && zhiWxIndex == 0) {
                    wangIndex = 1
                }
                else if (monthZhiIndex == 7 && zhiWxIndex == 1) {
                    wangIndex = 1
                }
                else if (monthZhiIndex == 10 && zhiWxIndex == 3) {
                    wangIndex = 1
                }
            }
            wangIndexList.push(wangIndex)
            wangNameList.push(wangArr[wangIndex])
        }

        tianPanObj.wangIndexList = wangIndexList
        tianPanObj.wangNameList = wangNameList
    },
    //获取旺根据月份
    getWang: function (ob, wx) {
        var monthZhiIndex = ob.monthZhiIndex
        var monthZhiWxIndex = ob.monthZhiWxIndex

        var zhiWxIndex = wx
        var wangIndex = (5 - (monthZhiWxIndex - zhiWxIndex)) % 5

        //丑月水相，辰月木相，未月火相，戌月金相
        if (monthZhiIndex % 3 == 1) {
            if (monthZhiIndex == 1 && zhiWxIndex == 4) {
                wangIndex = 1
            }
            else if (monthZhiIndex == 4 && zhiWxIndex == 0) {
                wangIndex = 1
            }
            else if (monthZhiIndex == 7 && zhiWxIndex == 1) {
                wangIndex = 1
            }
            else if (monthZhiIndex == 10 && zhiWxIndex == 3) {
                wangIndex = 1
            }
        }

        var wangName = wangArr[wangIndex]
        return wangName
    },
    //获取十二长生
    getChangShengList: function (tianPanObj, ob) {
        var changShengIndexList = []
        var changShengNameList = []
        var tianPanZhiIndexList = tianPanObj.tianPanZhiIndexList
        var dayGanWxIndex = ob.dayGanWxIndex

        var startZhi = changShengWxArr[dayGanWxIndex]

        for (var i = 0; i < 12; i++) {
            var offset = tianPanZhiIndexList[i] - startZhi
            offset = (offset < 0) ? offset + 12 : offset

            changShengIndexList[i] = offset
            changShengNameList[i] = changShengArr[offset]
        }

        tianPanObj.changShengIndexList = changShengIndexList
        tianPanObj.changShengNameList = changShengNameList

    },
    //获取是否包含
    containsList: function (list, str) {
        for (var i = 0; i < list.length; i++) {
            if (list[i].substr(0, 4).indexOf(str) > -1) {
                return list[i]
            }
        }
    },
    //点击展示详情
    showDetail: function (e) {
        var sMark = e.mark.smark
        var type = e.mark.type
        console.log("sMark: " + sMark);
        console.log("type: " + type);

        if (sMark != undefined) {
            if (type == "sha") {
                this.diyShaToast(this.getShaList('sui'))
            }
            else if (type == "chuanQin") {
                this.diytoast(sixQinDesc[sixQinArr.indexOf(sMark)])
            }
            else if (type == "ganZhi") {
                this.diytoast(this.containsList(ganZhiDesc, sMark))
            }
            else if (type == "procZhi") {
                this.diytoast(yueJiangDesc[11 - dzArr.indexOf(sMark)])
            }
            else if (type == "procJiang") {
                this.diytoast(tianJiangDesc[tianJiangArr.indexOf(sMark)])
            }
            else if (type == "siKeZhi") {
                if (tgArr.indexOf(sMark) > -1) {
                    this.diytoast(yueJiangDesc[11 - tlvJiGongGanArr[tgArr.indexOf(sMark)]])
                } else {
                    this.diytoast(yueJiangDesc[11 - dzArr.indexOf(sMark)])
                }
            }
            else if (type == "siKeJiang") {
                this.diytoast(tianJiangDesc[tianJiangArr.indexOf(sMark)])
            }
            else if (type == "changSheng") {
                this.diytoast(changShengDesc[changShengArr.indexOf(sMark)])
            }
        }
    },
    //获取煞内容
    getShaList: function (timeType) {
        // var text = ''
        var shaArr = []
        var shaRule = []

        var yearZhiIndex = this.yearZhiIndex
        var monthZhiIndex = this.monthZhiIndex
        var dayGanIndex = this.dayGanIndex
        var dayZhiIndex = this.dayZhiIndex

        var xunShouZhi = this.xunShouZhi
        var xunWeiZhi = this.xunWeiZhi
        var xunDingZhi = this.xunDingZhi
        var xunXinZhi = this.xunXinZhi

        if (timeType == 'sui') {
            shaRule = suiShaRule
            shaArr = this.getAllShaDesc('岁煞', shaRule, yearZhiIndex)
        } else if (timeType == 'ji') {
            shaRule = jiShaRule
            shaArr = this.getAllShaDesc('季煞', shaRule, monthZhiIndex)
        } else if (timeType == 'yue') {
            shaRule = yueShaRule
            shaArr = this.getAllShaDesc('月煞', shaRule, monthZhiIndex)
        } else if (timeType == 'gan') {
            shaRule = riGanShaRule
            shaArr = this.getAllShaDesc('干煞', shaRule, dayGanIndex)
        } else if (timeType == 'zhi') {
            shaRule = riZhiShaRule
            shaArr = this.getAllShaDesc('支煞', shaRule, dayZhiIndex)
        } else if (timeType == 'xun') {
            shaRule = xunShaRule
            var zhiArr = [xunShouZhi, xunWeiZhi, xunDingZhi, xunXinZhi]

            for (var i = 0; i < 4; i++) {
                var obj = shaRule[i]
                var name = obj.name
                var category = obj.category
                var desc = obj.desc

                var shaObj = new Object()
                shaObj.shaZhiIndex = zhiArr[i]
                shaObj.shaColor = wuXingColorArr[wuXingArr.indexOf(dzPArr[zhiArr[i]])]
                shaObj.shaType = '旬煞'
                shaObj.shaZhiName = dzArr[zhiArr[i]]
                shaObj.name = name
                shaObj.category = category
                shaObj.desc = desc
                shaArr.push(shaObj)
            }
        }

        return shaArr
    },
    //通过地支获取所有的煞
    getAllShaListByZhiName: function (zhiIndex) {
        var zhiIndexName = dzArr[zhiIndex]
        var shaArr = []
        var shaRule = []
        var zhiShaList = []

        var yearZhiIndex = this.yearZhiIndex
        var monthZhiIndex = this.monthZhiIndex
        var dayGanIndex = this.dayGanIndex
        var dayZhiIndex = this.dayZhiIndex

        var xunShouZhi = this.xunShouZhi
        var xunWeiZhi = this.xunWeiZhi
        var xunDingZhi = this.xunDingZhi
        var xunXinZhi = this.xunXinZhi

        shaRule = suiShaRule
        shaArr = shaArr.concat(this.getAllShaDesc('岁煞', shaRule, yearZhiIndex))
        shaRule = jiShaRule
        shaArr = shaArr.concat(this.getAllShaDesc('季煞', shaRule, monthZhiIndex))
        shaRule = yueShaRule
        shaArr = shaArr.concat(this.getAllShaDesc('月煞', shaRule, monthZhiIndex))
        shaRule = riGanShaRule
        shaArr = shaArr.concat(this.getAllShaDesc('干煞', shaRule, dayGanIndex))
        shaRule = riZhiShaRule
        shaArr = shaArr.concat(this.getAllShaDesc('支煞', shaRule, dayZhiIndex))
        shaRule = xunShaRule
        var zhiArr = [xunShouZhi, xunWeiZhi, xunDingZhi, xunXinZhi]

        for (var i = 0; i < 4; i++) {
            var obj = shaRule[i]
            var name = obj.name
            var category = obj.category
            var desc = obj.desc

            var shaObj = new Object()
            shaObj.shaZhiIndex = zhiArr[i]
            shaObj.shaColor = wuXingColorArr[wuXingArr.indexOf(dzPArr[zhiArr[i]])]
            shaObj.shaType = '旬煞'
            shaObj.shaZhiName = dzArr[zhiArr[i]]
            shaObj.name = name
            shaObj.category = category
            shaObj.desc = desc
            shaArr.push(shaObj)
        }

        for (var n = 0; n < shaArr.length; n++) {
            if (zhiIndexName == shaArr[n].shaZhiName) {
                zhiShaList.push(shaArr[n])
            }
        }
        return zhiShaList
    },
    //获取煞的详情数据
    getAllShaDesc: function (shaType, shaRule, index) {
        var shaArr = []
        var shaLen = shaRule.length

        console.log(shaRule)

        for (var n = 0; n < shaLen; n++) {
            var obj = shaRule[n]
            var name = obj.name
            var source = obj.source
            var destination = obj.destination
            var category = obj.category
            var desc = obj.desc
            var len = source.length

            for (var i = 0; i < len; i++) {

                if (source[i].indexOf(index) > -1) {
                    var shaObj = new Object()
                    shaObj.shaType = shaType
                    shaObj.shaZhiIndex = destination[i][0]
                    shaObj.shaColor = wuXingColorArr[wuXingArr.indexOf(dzPArr[destination[i][0]])]
                    shaObj.shaZhiName = dzArr[destination[i][0]]
                    shaObj.name = name
                    shaObj.category = category
                    shaObj.desc = desc
                    shaArr.push(shaObj)
                    break;
                }
            }
        }
        return shaArr
    },
    //通过type改变煞的内容
    showToastContentByType: function (e) {
        var type = e.detail

        if (type != undefined) {
            if (type == "sui" || type == "ji" || type == "yue" || type == "xun" || type == "gan" || type == "zhi") {
                this.changeToastContent(this.getShaList(type))
            }
        }
    },
    //断应期
    yingQi: function () {
        if (this.yingQiJump == false) {
            this.yingQiJump = true
            wx.navigateTo({
                url: '../yingqi/yingqi'
            })
        }
    }
})